Community Forums › Forums › Archived Forums › General Discussion › Conditional After Post Content
- This topic has 6 replies, 4 voices, and was last updated 10 years, 11 months ago by surefirewebserv.
-
AuthorPosts
-
April 12, 2013 at 6:18 am #34959smallbusinessguyMember
For after the post content (Where you can input email to subscribe), is it possible to show different content based on the post or post category? I want after post content A to appear for category A and after post content B to appear for category B.
Can someone give me a sample code as to how to make it work?
Thank you in advance.
April 12, 2013 at 8:39 am #34985surefirewebservMemberHere you go:
http://surefirewebservices.com/genesis-framework/how-to-add-a-cool-code-block-to-the-end-of-your-posts
SureFireWebServices.com | Genesis Tuts and More
Genesis Theme Starter Kit | It’s FreeApril 12, 2013 at 11:03 am #35028smallbusinessguyMemberThanks.
I did not understand the following part.
include( 'path/to/pwdc.html' );
else
include( 'path/to/genesis.html' );I am trying to add mailchimp subscribe code (Different subscribe code for different categories). Should I include it in a particular file and call it?
Thank you,.
April 12, 2013 at 11:27 am #35033AnitaKeymasterBrian Gardner has a this - http://www.briangardner.com/code/add-after-post-widget/ for adding an After Post Widget that you can use.
Love coffee, chocolate and my Bella!
April 12, 2013 at 12:01 pm #35038smallbusinessguyMemberHi Anitac,
I am current using that code on my site. It's working fine. My requirement is to show different such code based on the page people come to. E.g: A post about web design should display my web design list from mailchimp. An article about marketing should display the lead capture for my marketing list from mailchimp.
April 12, 2013 at 12:07 pm #35041SummerMemberFor that, I'd recommend using the Dynamic Widgets plugin, http://wordpress.org/extend/plugins/dynamic-widgets/
I'm currently using it on several sites, and it's very easy to control which widgets are displayed on categories, pages, etc.
WordPress / Genesis Site Design & Troubleshooting: A Touch of Summer | @SummerWebDesign
Slice of SciFi | Writers, After DarkApril 12, 2013 at 12:36 pm #35046surefirewebservMemberYou can either add the code to a page or add the code to your functions file. You would replace the include paths to your new html file that you made, or you can replace the include with the actual code.
add_action( 'genesis_after_post_content','sf_affiliate_block' );
/**
* Add affiliate box template to end of single post.
*
* If post is in Better Web Design category (190), use a different template.
*
* @since 1.0.0
* @author Sure Fire Web Services
* @link http://surefirewebservices.com/?p=1521
*
* @return Return null if not a single post.
*/
function sf_affiliate_block() {
if ( ! is_single() )
return;if ( in_category( '190' ) ) // if in the category with an id of 190
// echo 'your new code' or include your file
else
// echo 'a different code' or include your file
}I use this same exact code to add my after post files. If you go on my site, anything that has to do with genesis (or is in the genesis category) will get a "built on genesis" block of text after the post, while every other post with get a "learn web design" block of text.
Bottom line, there are multiple ways to handle this. The plugins will definitely work, (another plugin recommendation would be simple sidebars) or you can code it directly into the functions.php file. They all work.
SureFireWebServices.com | Genesis Tuts and More
Genesis Theme Starter Kit | It’s Free -
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.