Tagged: after-post widget
I am using the after post widget. I would like to be able to display different content depending on the post category.
Example: Post category 1 displays content 1
Post category 2 displays content 2
Thanks in advance
You can do this at least 2 ways.
1. Using a custom field
2. Creating multiple widgets.
Thanks very much. Could you please clarify.
I can cut and paste code but this is a bit confusing for me.
The code above would create a new after post widget for category. Correct?
Place this at the bottom of my child theme PHP file?
This is the child theme php showing my existing after post widget
Please copy the PHP code from the view raw link and paste it at the end of your child themes functions.php file.
You will need to edit this part of the code with the slug or category i.d for one category.
if ( in_category(007)
if ( in_category(web-design)
In the above example, 007 is the category i.d. and web-design is the category slug.
This will create a widget which displays content after all posts in that specific category.
Duplicate the solution for each category or use the other option which is to create a custom field.
Ok that worked great
But I must be missing something to duplicate the widget for another category.
I tried duplicating it and it created an error.
Do I have to rename or something?
Here's an example:
You must be logged in to reply to this topic.
Subscribe to get early access to new themes, discounts and brief updates about what's new with StudioPress!