I wanna change the href of a specific menu item on all pages. Is this possible? Where should I put the code?
I also added this javascript to the end of a specific page:
<script type="text/javascript">
document.getElementById("menu-item-100").href="xyz.php";
</script>
It didn't work even though when I viewed the page source it showed that the script was placed after the original href of the menu.
I don't wanna use custom links.
Try putting this in your footer.php
<script>
jQuery(document).ready(function($) {
$("#menu-item-100").attr("href", new_href);
});
</script>
Wordpress a lot of the times needs to have jQuery(document).ready(function($) for no-conflict reasons.
Try it, may be helpful to you:
$("#menu-item-100").attr("href", new_href);
Apparently the element with the ID of menu-item-100 had an a tag inside of it; so I had to retarget the whole thing.
This fixed the whole thing.
document.getElementById('menu-item-100').getElementsByTagName('a')[0].href="THE LINK";
Thanks to #NooBskie I put it inside the footer.php and it affected all the pages.
Related
Here is my problem, I have an iframe of a wordpress page (with stripped header/fooder/sidebar) with lots of links and I want when the user clicks on the links for them to open on the parent window and not the iframe.
I know I can use:
<a target="_parent" href="http://url.org">link</a>
on the links, but since the links point to wordpress posts and the list of posts is updated dynamically, this isn't a very good option. I can't edit them one-by-one to add the target. Plus, it might interfere with the rest of the site's links.
Another option is to use
<base target="_parent">
on the iframe header but I don't know how to do that.
Suppose I have this code to add the iframe:
<iframe class="bg-dark3" style="border: none;" src="https://www.google.com" scrolling="no"></iframe>
Where and how can I add the <base target="_parent"> line?
You can add this to your Wordpress site. It's Jquery to open the links in the parent. So please make sure Jquery library is loaded.
$('a').click(function(){
//Get url from anchor
var link = $(this).attr('href');
//Open url in parent
window.parent.parent.window.location = link;
});
This will automatically open the links in the parent, you wouldn't need to add target=_parent to each link manually.
How can I remove the text background=""> from my Wordpress site?
The address is https://www.mybestroadbikes.com
Thanks!
You need to delete if from the page source itself.
Here is where is the extra String
Hope this helps :)
EDIT:
I am not sure how you page is structured in WordPress but you can try when you are on the home page just click Edit Page in the top menu.
After that you will ed up in a Dashboard window with some RichTextBox on it. On the right side you have to option to switch to Text instad of Visual. When you do that I think you will be able to locate the extra String and remove it:
Please check your body tag in header.php
The tag must must have been closed incorrectly.
You've got an issue with whatever mechanism you have used to insert Google Tag Manager. Use another method to whatever you have used or check your syntax because there's a syntax error with it. You can easily embed the script in the header using the hook wp_head.
function child_theme_head_script() { ?>
<script>
//Script here
</script>
<?php
}
add_action( 'wp_head', 'child_theme_head_script' );
Hi I have been trying to change 1 word of text within the Avada theme.
Here is the line of text: http://prntscr.com/ibac1t
This is on all gallery pages, but here is one page for example: http://preview.geomedia.co.uk/nursteadcourt/our-destination/wedding-5/?portfolioCats=24%2C21%2C23%2C22
I can't seem to find where it is to change, I would like to change the word 'Projects' to either: Pictures or Gallery's. This is probably more complex than I think it will be.
Any assistance in this would be great.
Thanks
You can find this in the file located at
/website_folder/wp-content/themes/Avada/includes/avada-functions.php.
It is in the "avada_render_related_posts" function and at/around line 327.
Copy the file to your child theme folder or else you will have to update this file after every theme update.
Hope this helps.
We use something similar to this:
<script type="text/javascript">
jQuery(document).ready(function() {
/*<![CDATA[*/
jQuery('.related-posts > div > h3').html('Posts Relacionados');
/*]]>*/
});
</script>
As soon as you create a menu item for a page there is a link that it automatically populated with it. How do i stop wordpress from making these links? I'm capable of making them myself and don't always want them to link to thier specific page.
I figured it out using and dropping it in my header.php
<script type="text/javascript">
jQuery(function($) {
$("li.menu-item-627,li.menu-item-14,li.menu-item-20,li.menu-item-28").children("a").attr('href', "javascript:void(0)");
});
</script>
You have to use firebug or chrome "inspect element" to find out what your menu items are and then just replace the numbers in the code accordingly.
also if you don't want them to show up at all add the following code
<script type="text/javascript">jQuery(function($) { $("li.menu-item-627").contents().hide();});</script>
those two together will hide the disabled menu link
you can then add your own links in the "navigation label" of the page menu field!
good luck and let me know if you have any questions, i will do my best to help!
As far as I am aware in Tumblr there is no {block:Pages} block, so anything we add to normal posts is added to pages as well, things like sharing and worst of all, comment systems.
Does anyone know of a hack, or any way to remove/hide elements from pages? It's difficult because pages are using the {block:Permalink} {block:Text} blocks, so I'm pretty stumped.
I recently just discovered how to modify CSS with post tags using just HTML over here: Tumblr: How to control CSS with post tagging (UPDATE: Working Method without JQuery!)
I thought maybe we can use this, the idea would be something like this:
{block:Text}
<div class="post {block:HasTags}pagefix {block:Tags}{Tag}{/...}">
...
{/block:Text}
The way it works is by default we hide any element we don't want to be shown on pages (example: Disqus), adding the class .pagefix between {block:HasTags} in the div wrapper we can tell it to show elements on posts with tags, that way elements will only be shown on posts and not pages, because pages don't have tags.
Two problems with this, 1) all posts MUST be tagged in order to show any hidden items and 2) the Disqus comment script would have to be inserted into every post type, rather than just once before the {/block:Posts} end block.
I may be just placing Disqus in the wrong place, or some other error, let me know what you think, I can't find anything at all about this on the net anywhere. It's so dumb not to have a unique page block...
Simply wrap your Disqus code in the date block.
{block:Date}
<!-- Disqus code -->
{/block:Date}
Since only posts have dates, the Disqus code will never get rendered on a page. This also solves the problem above where having only one post breaks the method.
The trick is to wrap your Disqus code in {block:PermalinkPagination} tags as follows:
{block:PermalinkPagination}
...disqus code...
{/block:PermalinkPagination}
Your question is a partial duplication of this one on webapps.stackexhange.com, a full explanation can be found here.
There is also a problem with disqus code whereby if you want to have the comment count show on the front page but not a comment box (but have the comment box and comments as well as the comment count show on the Permalink page) you must do the following:
Append #disqus_thread to the direct page link e.g.
Do NOT wrap the disqus code in {block:PermalinkPagination}{/block:PermalinkPagination} as this will hide comments from the front page. Remove that block if it exists, and wrap the top part of the disqus script only in {block:Permalinkpage}{/block:Permalinkpage} - exact disqus code for Tumblr reproduced below;
{block:IfDisqusShortname}
{block:Permalinkpage}
<script type="text/javascript">var disqus_url = "{Permalink}"; var disqus_title ="{block:PostTitle}{PostTitle}{/block:PostTitle}";</script>
<div id="disqus_thread"></div>
<script type="text/javascript">
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://{text:Disqus Shortname}.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the comments powered by Disqus.</noscript>
{/block:Permalinkpage}
<!--{Title}'s comments powered by <span class="logo-disqus">Disqus</span>-->
<script type="text/javascript">
var disqus_shortname = '{text:Disqus Shortname}';
(function () {
var s = document.createElement('script'); s.async = true;
s.src = 'http://{text:Disqus Shortname}.disqus.com/count.js';
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
}());
</script>
{/block:IfDisqusShortname}
</div>