Adding Widget Areas to Wordpress Posts

Hey there,

I’d like to create two widget areas on my website’s blog posts (single posts):

  1. Under the blog post content but above comments
  2. After entry-header but before entry-wrap

I come from the Genesis world where there are hooks for everything, so this has been my starting point. However, if i look at the Pro documentation for actions and filters (https://theme.co/apex/forum/t/customizations-actions-and-filters-in-x-pro/208) there seems to be a limited quanity that won’t help me achieve the above goals.

I’d prefer to accomplish these goals without adding any additional plugins or editing core files. Can you point me in the right direction?

Hi There,

Please make sure you’ve already installed the child theme: https://theme.co/apex/forum/t/setup-how-to-setup-child-themes/57.

After that adding this code under fucntions.php file locates in your child theme:

add_action('x_after_view_global__content', 'widget_after_content');
function widget_after_content(){
  dynamic_sidebar('your-siderbar-1');
}

add_action('x_after_view_{your_stack}__content-post-header', 'widget_after_entry_header');
function widget_after_entry_header(){
  dynamic_sidebar('your-siderbar-2');
}

The code above will create 2 widget areas in your single post page. You can use the Unlimited Sidebars feature to create your sidebars:

Note: replace the {your_stack} in the custom with your stack.

Hope it helps :slight_smile:

Thank you, this is exactly what I was looking for. Is there documentation on all available hooks?

x_after_view_global__content
x_after_view_{your_stack}__content-post-header
etc.

You’re most welcome.

And to check the hooks and filters in the theme, this is the only article we have where in you can check it: https://theme.co/apex/forum/t/customizations-actions-and-filters-in-x-pro/208.
You might need to manually check each of the theme files if there is a hook or filter for you to be able to use in your modifications.

Best Regards.

I sourced https://theme.co/apex/forum/t/customizations-actions-and-filters-in-x-pro/208 in my initial post and the hooks provided by @thai aren’t listed in it. I’m asking for more comprehensive documentation - if it exists - so I don’t have to go through the theme files.

Hello There,

Regretfully we do not have any more articles that has all the lists of the actions hooks and filters. I will informed the person in charge with the knowledge base articles though so that it can be added and made available to anyone.

Thanks for understanding.

Understood. One last request here - can you also let me know the WP post hook for after the entry-featured section? That is, after entry-featured but before entry-wrap.

Hello There,

There is no action hook for that area. If you are using integrity, this is the code in that area:

<?php

// =============================================================================
// VIEWS/INTEGRITY/CONTENT.PHP
// -----------------------------------------------------------------------------
// Standard post output for Integrity.
// =============================================================================

?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  <div class="entry-featured">
    <?php x_featured_image(); ?>
  </div>
  <div class="entry-wrap">
    <?php x_get_view( 'integrity', '_content', 'post-header' ); ?>
    <?php x_get_view( 'global', '_content' ); ?>
  </div>
  <?php x_get_view( 'integrity', '_content', 'post-footer' ); ?>
</article>

If you want to add something in between the entry-featured and entry-wrap, please do the following assuming you have your child theme active and ready:
1] Using Notepad or TextEdit or Sublime Text or any text editor, please create a new file in your local machine.
2] Insert the following code into that new file

<?php

// =============================================================================
// VIEWS/INTEGRITY/CONTENT.PHP
// -----------------------------------------------------------------------------
// Standard post output for Integrity.
// =============================================================================

?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  <div class="entry-featured">
    <?php x_featured_image(); ?>
  </div>

<p>Add your modifications here</p>

  <div class="entry-wrap">
    <?php x_get_view( 'integrity', '_content', 'post-header' ); ?>
    <?php x_get_view( 'global', '_content' ); ?>
  </div>
  <?php x_get_view( 'integrity', '_content', 'post-footer' ); ?>
</article>

3] Save the file named as content.php
4] Upload this file to your server in the child theme’s folder wp-content/themes/x-child/framework/views/integrity/.

You will need to create the folder path since it does not exist in your child theme.

Hope this help

Thank you so much!

You are most welcome!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.