Struggling to get Post Sidebars setup

Hi. I am trying to get my posts and related post sidebars set-up and have used the kb1 https://theme.co/apex/forums/topic/adding-a-sidebar-to-a-blog-post-only/ as well as the kb2 https://theme.co/apex/forums/topic/create-sidebar-for-post-category/ as my guide.

My blog page (https://mysalus.org/community/town-hall/) is using The Grid plugin which pulls from 4 grids, each grid with their own distinct post type). Each post displays, with a blank sidebar. My issue is I can not seem to get sidebars assigned to the different single post pages.

Issue 1. When I assign my /town-hall page to the settings>reading > post page, a post page id 47971 (correct post id) but with “sudo text” -see attached screenshot - appears instead of the correct /town-hall content which displays normally if not set in settings>reading > post page. I’m conused here. Do I need to have my /town-hall page set to the post page in the reading pane for the main sidebar to show on the single posts?

I have a blank page setup https://mysalus.org/blog-page/ that shows the erroneous content described above. Once I get this working as it should be, I would like to assign my other three custom post types … slugs are - members, partners, storefronts etc. to have their own side bars.
What I have tried thus far;

  1. Using kb1, i have set custom sidebars for single post types" and code snippets as follows. If I can get this default wp post set right and working I would plan to do the same for my other custom post types.

add_filter( ‘ups_sidebar’, ‘assign_engagement_sidebar’);

function assign_single_sidebar($sidebar){

    if (is_date() ){
         return 'ups-sidebar-single-post';        
     }

return $sidebar;
}
add_filter( ‘ups_sidebar’, ‘assign_single_sidebar’);

Thanks in advance for your help with this.

Hello @dsthompson,

Thanks for writing in! :slight_smile:

You don’t have to set that page in Setting > Readings > Post Page for your sidebar to show.

Can you share us your Wordpress & FTP User/Pass in a secure note so we can take a closer look?

Thank you.

Hi there,

As you set your Blog page using The Grid you should not assign that page to Settings > Reading > Posts Page as doing that overrides the whole process and uses the default archive template of the theme.

So leave that page alone and consider it as your blog page and set the posts page to nothing in Settings > Reading.

Now for that page which you used The Grid, you can create a Sidebar and assign it to that page. For more information:

Then you can go to Appearance > Widgets and assign whatever widget you like to that sidebar which will show in the page with The Grid.

For the single posts, you can use simply the Main Sidebar widget area in the Appearance > Widgets menu.

Finally, to add a specific sidebar to your custom post types you need to install a Child Theme and add the PHP code below to the functions.php file of your Child Theme:

add_filter( 'ups_sidebar', 'portfolio_sidebar' );

function portfolio_sidebar($sidebar){
	if(x_is_portfolio_item()){
		return 'ups-sidebar-portfolio';
	}

	if (get_post_type(get_the_ID()) == 'mec-events') {
		return 'ups-sidebar-portfolio';	
	}
	return $sidebar;
}

Change ups-sidebar-portfolio with the ID of the sidebar which you created:

Change mec-events with the slug of your custom post type.

After that, you can go to Appearance > Widgets and assign widgets to the sidebar you created for the custom post type.

Thank you.

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