Tagged: x
-
AuthorPosts
-
August 3, 2016 at 2:06 pm #1115900
TrankuilityParticipantThe majority of my users come from several different states in the US. I mark each post with a category that relates to that state, i.e. Florida.
When someone visits a post marked with Category Florida, I want to show an optin specific to Florida people.
I spoke to the devs at Pushcrew (the optin service) and they gave me the code to place on each post in the category. However, I am wondering if there’s a way that I can add the code in Xtheme somewhere and it would automatically place the code on all posts marked with the category.
So my questions is: How do I add a snippet of code to all posts that are marked with a specific category?
August 3, 2016 at 4:25 pm #1116104
FriechModeratorHi There,
Thanks for writing in! You can add this on your child theme’s functions.php file
function share_for_posts( $content ) { if ( is_singular('post') ) { if ( in_category( 'YOUR CATEGORY' )): ?> /*YOUR snippet of code HERE*/ <?php endif; } } add_action('x_before_the_content_end', 'share_for_posts');Replace the YOUR CATEGORY with your actual category name or ID.
Hope it helps, Cheers!
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1115900 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
