- This topic has 11 replies, 6 voices, and was last updated 6 years, 5 months ago by
heliosmp.
-
AuthorPosts
-
January 13, 2015 at 2:23 pm #64776
George
This probably stems from my general inexperience with all things webdesign & programming, but is there a way that I can have a hook display only on certain pages? I am using the hooks feature to display breadcrumbs from the Yoast SEO plugin, and I have the PHP code set for “Before content”. Ideally, I would only display the breadcrumbs when in full post view. Right now, the breadcrumbs display on the main blog page and category/tag pages, and I would like to be able to restrict them to just single posts.
Here’s the PHP if that matters at all:
<?php if ( function_exists('yoast_breadcrumb') ) { yoast_breadcrumb('<p id="breadcrumbs">','</p>'); } ?>
Thanks!
January 13, 2015 at 8:04 pm #64848Tom
Lead DeveloperLead DeveloperYou can use WordPress if conditionals: http://codex.wordpress.org/Conditional_Tags
This one specifically would be:
<?php if ( is_single() ) : ?> <?php if ( function_exists('yoast_breadcrumb') ) { yoast_breadcrumb('<p id="breadcrumbs">','</p>'); } ?> <?php endif; ?>
January 14, 2015 at 1:44 pm #65134George
Great, the code worked excellently. Thanks a ton!
January 14, 2015 at 7:02 pm #65246Tom
Lead DeveloperLead DeveloperYou’re welcome ๐
January 29, 2015 at 8:31 am #70009Carlos Paramio
I’m also playing with the Yoast SEO plugin and have put breadcrums ‘Before content’ with GP Hooks.
Tom, following that link you posted I have set ‘is_singular()’ for the breadcrums apperaing when you open “A Single Page, a Single Post, an Attachment or Any Other Custom Post Type”But I don’t know if that’s exactly what I need: I want the breadcrums to appear wherever you are (posts, pages, subpages, etc.) except when you’re in the home page
Do you have a better code for that?
Merci
January 29, 2015 at 5:11 pm #70189Tom
Lead DeveloperLead DeveloperHi Carlos,
You can use this code to show something on all pages except the homepage:
<?php if ( ! is_front_page() ) : ?> Your stuff in here <?php endif; ?>
January 30, 2015 at 12:12 am #70255Carlos Paramio
Awesome, that’s exactly what I needed
Lot of help from you these days!January 30, 2015 at 9:47 am #70429Tom
Lead DeveloperLead DeveloperHappy to help! ๐
February 2, 2015 at 10:54 pm #71532Joseph
February 2, 2015 at 10:56 pm #71533Joseph
Hi Thomas, I used this code on my site right below header, it works fine but the last image (editionRev.png> does not stay inline when I go responsive?
<div style=”margin-top:-219px;margin-bottom:130px;margin-left:10%;” class=”grid-container grid-parent”>
</div>Also this Div is pushed down to the Secondary Menu.
Any suggestions welcomed Thank you!
February 3, 2015 at 12:14 am #71535Tom
Lead DeveloperLead DeveloperHi there,
That’s because you’re using inline styles which you can’t tweak for mobile.
You may want to try adding a class to your div, and then applying your css to the div when not in mobile:
@media screen and (min-width: 769px) { .sample-class { margin-top:-219px; margin-bottom:130px; margin-left:10%; } }
April 13, 2017 at 2:40 am #305338heliosmp
Hi Carlos,
You can use this code to show something on all pages except the homepage:
<?php if ( ! is_front_page() ) : ?>
Your stuff in here
<?php endif; ?>Hi Tom,
What about if I want to show the GPhook only on the front page and not on any other pages?
Br, Mark
EDIT:
Found the info in this post. -
AuthorPosts
- You must be logged in to reply to this topic.