• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2784

Original Genesis Tutorials & 6000+ Guaranteed Code

Snippets

  • Consultation
  • Full Access
  • Log in

Displaying Content Only After Single Posts With Specific Tag

If you want to display the same content in the same position, on specific posts only, this tutorial is for you. This code will create a new custom widget area where you can add content to display immediately after specific posts.

Simply change the hook position to display your content in another position in your theme.

The widget outputs your content only on posts which you tag with the word ‘custom’.

Note: The code above uses the old XHTML hooks. The below code uses the new HTML 5 hooks.

You can also use another conditional tag if you want to display content on tag archives.

Basically, this code creates a custom widget for tagged posts and only posts using a specific tag will output the content you populate in this widget.

If you want your content to display before your Jetpack sharing buttons, you will need to move them to another hook position which is easy if you’re a Genesis user.

You could also use the

genesis_post_content or genesis_entry_content hook

with a high priority to hook your widget content in immediately after the main content area of single posts.

Different Content – Same Position

If you wanted to display different content in the same hook position on single posts using a specific tag, you would be far better off to create a custom field which hooks into that position.

Changing The Conditions for Categories

You can easily change the conditional tag so your widget content only displays on specific posts in a category.

Change this line:

if ( is_single() && has_tag('custom') && is_active_sidebar( 'custom-tagged' ) ) {

to this:

if ( is_single() && in_category('custom') && is_active_sidebar( 'custom-tagged' ) ) {

Need Further Customization?

Ask away in the comments if you would like this code modified further

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags