Plugin Support
Nick C
(@modernnerd)
Hi, MeasuringFlower!
WordPress provides “Conditional Tags” that let you output content depending on the current page you’re viewing: https://codex.wordpress.org/Conditional_Tags. You can use them with Genesis Simple Hooks or in your theme’s template files.
For example, to display content or run PHP everywhere except for your static homepage, you could put this code in any Content Hooks box, being sure to tick “Execute PHP on this hook” next to the box:
<?php
if ( ! is_front_page() ) {
echo "<p>Hello, I'm your new content!</p>";
}
?>
The ! before is_front_page() can be read as ‘not’, as in if not front page. You can add that ! before any conditional tag to make it negative. You can also chain conditional tags together with ‘or’ as well as ‘and’ operators: http://php.net/manual/en/language.operators.logical.php
For single posts, you can use the is_single() conditional tag: https://codex.wordpress.org/Conditional_Tags#A_Single_Post_Page
Thread Starter
TheTJ
(@measuringflower)
Hi, Nick. Thanks. 🙂 I got the HTML to work perfectly. 😀
However, I can’t get the php bit to work. I’d like this bit of PHP to show only in single posts (I have no single.php file so can’t do that, hence the reason I’m trying to use Genesis Simple Hooks):
<?php zemanta_related_posts()?>
I’ve tried to make sense of codex stuff and put it to work, but I just can’t get it. 🙁
Plugin Support
Nick C
(@modernnerd)
Hi, MeasuringFlower. Have you tried something like this?
<?php
if ( is_single() && function_exists( 'zemanta_related_posts' ) ) {
zemanta_related_posts();
}
?>
That should work if you place it in one of the content areas and tick, “Execute PHP on this hook”.
Thread Starter
TheTJ
(@measuringflower)
That did the trick! Thanks for your help, Nick! 😀