Learn how to introduce in Custom Post Types (CPTs) the widget area that normally appears after Genesis Framework entries by code.
It is very common to find Genesis child themes that contain an “After the post” widget.
This is the one after the post content and just before the comments.
It is often used to add a call to action (CTA), such as a form for readers to subscribe to the newsletter.
In general it makes sense that it is restricted to posts, but your customer may be interested in showing it, for example, in their portfolio.
Are you in that situation? Read on and find out how to do it. 😉
Code to add the widget that goes after the posts to the CPTs
Insert this snippet at the end of the functions.php file:
To see this and another 1097 code snippets of this website, login or subscribe here.
With this step you support the widget to be displayed in the portfolio CPT (whose slug is ‘portfolio’), but you can modify it and add the slug of your Custom Post Type (‘products’, ‘events‘…).
What if you are not using Genesis Sample and your theme does not have this widget area?
No problem, just enter the following snippet infunctions.php:
// Add support for the widget area after the entry
add_theme_support( 'genesis-after-entry-widget-area' );
Note, however, that in this case you may need to make minor CSS adjustments to ensure that it looks right.
Conclusions
The post-entry widget area in Genesis is very convenient for placing information you want to display at the end of each content.
By default, its display is restricted to posts, but by applying the code snippet above you can get it to appear in the Custom Post Types of your child theme as well.
Any questions? Let me know in the comments.
And if you want to give me any suggestion for future tutorials, leave it in the contact form. Advantages of being a subscriber. 😉