Jump to content
Sign in to follow this  
marvage

Best way to add conditional content to posts in Platform?

Recommended Posts

marvage

I'd like to add content to posts, just under the tags section, and use a conditional statement to show that content only in a particular category (I'll call it foo). I would like this content to appear whenever foo posts are displayed (on post pages, single post pages, etc) I'm using this code for the conditional statement. <?php if (in_category('foo')) { ?><div class="foo">Foo is great.</div><?php } ?> I see where I could add the statement in the loop and I'm assuming I copy over template.postloop.php to the base and make the edit there. Or, can I use functions.php to do this? Or, am I looking at doing something else? Hoping you can suggest the best approach. I'd read through the forums and docs but feel like I missing something. Thanks!

Share this post


Link to post
Share on other sites
marvage

Thanks Mark - that's great. I'd tried hooks but had the wrong one. Now it works perfectly. Will check out the documentation. Cheers!

Share this post


Link to post
Share on other sites
makeylon

Unfortunately, there isn't an all encompassing list of hooks and locations. However, you can look for some hooks in the template layout section where each drag and drop section can be expanded to show what hooks are in that section. Also, if you look through the various templates, in this case I looked through the template.postloops.php page, you can find various hooks and their locations within the file.

Share this post


Link to post
Share on other sites
marvage

No worries and thanks for that tip. I'll keep that in mind next time I work with hooks. Overall, I'm really enjoying working with this theme. The ability to customize is amazing. Cheers

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×