<?xml version="1.0" encoding="UTF-8"?>
	<rss version="2.0"
		xmlns:content="http://purl.org/rss/1.0/modules/content/"
		xmlns:wfw="http://wellformedweb.org/CommentAPI/"
		xmlns:dc="http://purl.org/dc/elements/1.1/"
		xmlns:atom="http://www.w3.org/2005/Atom"

			>

	<channel>

		<title>Create Sidebar for Post Category &#8211; Themeco Community</title>
		<atom:link href="https://theme.co/archive/forums/topic/create-sidebar-for-post-category/feed/" rel="self" type="application/rss+xml" />
		<link>https://theme.co/archive/forums/topic/create-sidebar-for-post-category/feed/</link>
		<description></description>
		<lastBuildDate>Sat, 18 Oct 2025 04:37:09 +0000</lastBuildDate>
		<generator>https://bbpress.org/?v=2.6.14</generator>
		<language>en-US</language>

		
														
					
				<item>
					<guid>https://theme.co/archive/forums/topic/create-sidebar-for-post-category/#post-149369</guid>
					<title><![CDATA[Create Sidebar for Post Category]]></title>
					<link>https://theme.co/archive/forums/topic/create-sidebar-for-post-category/#post-149369</link>
					<pubDate>Thu, 20 Nov 2014 18:27:21 +0000</pubDate>
					<dc:creator>Frank19</dc:creator>

					<description>
						<![CDATA[
						<p>I&#8217;m attempting to create a new sidebar that shows for all posts within a specific category.  I created the sidebar and selected the category taxonomy from the options but for some reason it is not showing within that category on the front end.  Am I missing something?</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/create-sidebar-for-post-category/#post-149821</guid>
					<title><![CDATA[Reply To: Create Sidebar for Post Category]]></title>
					<link>https://theme.co/archive/forums/topic/create-sidebar-for-post-category/#post-149821</link>
					<pubDate>Fri, 21 Nov 2014 12:06:41 +0000</pubDate>
					<dc:creator>Zeshan</dc:creator>

					<description>
						<![CDATA[
						<p>Hi there,</p>
<p>Thanks for writing in! To assist you with this issue, we&#8217;ll first need you to provide us with your URL as stated on the forum entrance page. This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you.</p>
<p>Thanks!</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/create-sidebar-for-post-category/#post-149847</guid>
					<title><![CDATA[Reply To: Create Sidebar for Post Category]]></title>
					<link>https://theme.co/archive/forums/topic/create-sidebar-for-post-category/#post-149847</link>
					<pubDate>Fri, 21 Nov 2014 13:10:01 +0000</pubDate>
					<dc:creator>Frank19</dc:creator>

					<description>
						<![CDATA[
						<p>Sorry, here is my site URL:</p>
<blockquote class="wp-embedded-content" data-secret="TbKFlGt57L"><p><a href="https://golficity.com/" rel="nofollow">Golficity</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; visibility: hidden;" title="&#8220;Golficity&#8221; &#8212; Golficity" src="https://golficity.com/embed/#?secret=8IZB5XaZWC#?secret=TbKFlGt57L" data-secret="TbKFlGt57L" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p>And here is an example of a post within the category where I am attempting to create a custom sidebar:</p>
<blockquote class="wp-embedded-content" data-secret="0IfjnSGYZB"><p><a href="https://golficity.com/golf-podcast-052-bounce-back-bad-round-of-golf/" rel="nofollow">Golf Podcast 052: How to Bounce Back After a Bad Round of Golf</a></p></blockquote>
<p><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; visibility: hidden;" title="&#8220;Golf Podcast 052: How to Bounce Back After a Bad Round of Golf&#8221; &#8212; Golficity" src="https://golficity.com/golf-podcast-052-bounce-back-bad-round-of-golf/embed/#?secret=Zm3ipEtOkE#?secret=0IfjnSGYZB" data-secret="0IfjnSGYZB" width="600" height="338" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p>Thanks.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/create-sidebar-for-post-category/#post-150309</guid>
					<title><![CDATA[Reply To: Create Sidebar for Post Category]]></title>
					<link>https://theme.co/archive/forums/topic/create-sidebar-for-post-category/#post-150309</link>
					<pubDate>Sat, 22 Nov 2014 03:56:57 +0000</pubDate>
					<dc:creator>Rad</dc:creator>

					<description>
						<![CDATA[
						<p>Hi Frank,</p>
<p>You mean each post should have the sidebar assigned from each category?</p>
<p>Because this requires a template change, I&#8217;d advise that you setup a <a href="http://theme.co/x/member/kb/how-to-setup-child-themes/" title="Child Themes" target="_blank" rel="nofollow">child theme</a>. This allows you to make code changes that won&#8217;t be overwritten when an <strong>X</strong> update is released. After your child theme is setup, please review how we recommend making template changes in <a href="http://theme.co/x/member/kb/customization-best-practices/" rel="nofollow">Customization Best Practices</a>.</p>
<p>Add this code at your child theme’s functions.php</p>
<pre><code>function post_category_add_meta_field() {
  // this will add the custom meta field to the add new term page
  ?&gt;
  &lt;div class=&quot;form-field&quot;&gt;
    &lt;label for=&quot;term_meta[post-category-sidebar]&quot;&gt;&lt;?php _e( &#039;Item\&#039;s Sidebar&#039;, &#039;__x__&#039; ); ?&gt;&lt;/label&gt;
    &lt;select name=&quot;term_meta[post-category-sidebar]&quot; id=&quot;term_meta[post-category-sidebar]&quot;&gt;&lt;?php echo post_category_sidebar_options(); ?&gt;&lt;/select&gt;
    &lt;p class=&quot;description&quot;&gt;&lt;?php _e( &#039;Select Sidebar&#039;,&#039;__x__&#039; ); ?&gt;&lt;/p&gt;
  &lt;/div&gt;
&lt;?php
}

function post_category_edit_meta_field($term) {
 
  // put the term ID into a variable
  $t_id = $term-&gt;term_id;
 
  // retrieve the existing value(s) for this meta field. This returns an array
  $term_meta = get_option( &quot;taxonomy_$t_id&quot; ); ?&gt;
  &lt;tr class=&quot;form-field&quot;&gt;
  &lt;th scope=&quot;row&quot; valign=&quot;top&quot;&gt;&lt;label for=&quot;term_meta[post-category-sidebar]&quot;&gt;&lt;?php _e( &#039;Item\&#039;s Sidebar&#039;, &#039;__x__&#039; ); ?&gt;&lt;/label&gt;&lt;/th&gt;
    &lt;td&gt;
    &lt;select name=&quot;term_meta[post-category-sidebar]&quot; id=&quot;term_meta[post-category-sidebar]&quot;&gt;&lt;?php echo post_category_sidebar_options( $term_meta[&#039;post-category-sidebar&#039;] ); ?&gt;&lt;/select&gt;
      &lt;p class=&quot;description&quot;&gt;&lt;?php _e( &#039;Select Sidebar&#039;,&#039;__x__&#039; ); ?&gt;&lt;/p&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
&lt;?php
}

add_action( &#039;post-category_edit_form_fields&#039;, &#039;post_category_edit_meta_field&#039;, 10, 2 );
add_action( &#039;post-category_add_form_fields&#039;, &#039;post_category_add_meta_field&#039;, 10, 2 );

function save_post_category_custom_meta( $term_id ) {
  if ( isset( $_POST[&#039;term_meta&#039;] ) ) {
    $t_id = $term_id;
    $term_meta = get_option( &quot;taxonomy_$t_id&quot; );
    $cat_keys = array_keys( $_POST[&#039;term_meta&#039;] );
    foreach ( $cat_keys as $key ) {
      if ( isset ( $_POST[&#039;term_meta&#039;][$key] ) ) {
        $term_meta[$key] = $_POST[&#039;term_meta&#039;][$key];
      }
    }
    // Save the option array.
    update_option( &quot;taxonomy_$t_id&quot;, $term_meta );
  }
}  
add_action( &#039;edited_post-category&#039;, &#039;save_post_category_custom_meta&#039;, 10, 2 );  
add_action( &#039;create_post-category&#039;, &#039;save_post_category_custom_meta&#039;, 10, 2 );

function post_category_sidebar_options ( $default ) {
  $sidebars = get_option( &#039;ups_sidebars&#039; );
  $option = &#039;&lt;option value=&quot;sidebar-main&quot; &#039;.( !isset($default) || empty($default) || $default == &#039;sidebar-main&#039; ? &#039; selected &#039; : &#039;&#039; ).&#039;&gt;Default&lt;/option&gt;&#039;;
  foreach ( $sidebars as $id =&gt; $sidebar ) {
      $option .= &#039;&lt;option value=&quot;&#039;.$id.&#039;&quot; &#039;.( $id==$default ? &#039; selected &#039; : &#039;&#039; ).&#039;&gt;&#039;.$sidebar[&#039;name&#039;].&#039;&lt;/option&gt;&#039;;
  }
  return $option;
}</code></pre>
<p>2. Copy <strong>wp-single.php</strong> from <strong>▸ wp-content ▸ themes ▸ x ▸ framework ▸ views ▸ {STACK}</strong> to your child theme (eg. <strong>▸ wp-content ▸ themes ▸ x-child-{STACK} ▸ framework ▸ views ▸ {STACK}</strong>  ) </p>
<p>3. Edit your child theme&#8217;s wp-single.php and replace this line of code :</p>
<p><code>&lt;div class=&quot;&lt;?php x_main_content_class(); ?&gt;&quot; role=&quot;main&quot;&gt;</code></p>
<p>with this :</p>
<p><code>&lt;div class=&quot;x-main right&quot; role=&quot;main&quot;&gt;</code></p>
<p>and this one :</p>
<pre><code>&lt;?php if ( $fullwidth != &#039;on&#039; ) : ?&gt;
      &lt;?php get_sidebar(); ?&gt;
    &lt;?php endif; ?&gt;</code></pre>
<p>with this :</p>
<pre><code>&lt;aside class=&quot;x-sidebar left&quot; role=&quot;complementary&quot;&gt;

&lt;?php

$terms = get_the_terms( get_the_ID(), &#039;category&#039; );

if ( !isset( $terms ) &amp;&amp; count( $terms ) == 0 ) $sidebar = &#039;sidebar-main&#039;;
else {

    $term = array_pop( $terms );
    $setting = get_option( &quot;taxonomy_&quot;.$term-&gt;term_id );
    $sidebar = $setting[&#039;post-category-sidebar&#039;];
}

dynamic_sidebar( $sidebar );

?&gt;

&lt;/aside&gt;</code></pre>
<p>4. Save and upload.</p>
<p>With this customization, it will allow you to set your custom sidebar per category. You may add or edit your category at Admin &gt; Posts &gt; Categories and set your sidebar. If there is no sidebar, then it will use main sidebar. Please also note that if your items has multiple category, then it will pickup the last category and use its sidebar.</p>
<p>Hope this helps.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/create-sidebar-for-post-category/#post-150480</guid>
					<title><![CDATA[Reply To: Create Sidebar for Post Category]]></title>
					<link>https://theme.co/archive/forums/topic/create-sidebar-for-post-category/#post-150480</link>
					<pubDate>Sat, 22 Nov 2014 15:00:44 +0000</pubDate>
					<dc:creator>Frank19</dc:creator>

					<description>
						<![CDATA[
						<p>Sorry, maybe I&#8217;m not fully understanding then.  What then is the function of the taxonomies selection in the custom sidebar creation?  I was under the impression that was how I could assign a sidebar to a certain category.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/create-sidebar-for-post-category/#post-150939</guid>
					<title><![CDATA[Reply To: Create Sidebar for Post Category]]></title>
					<link>https://theme.co/archive/forums/topic/create-sidebar-for-post-category/#post-150939</link>
					<pubDate>Sun, 23 Nov 2014 12:19:18 +0000</pubDate>
					<dc:creator>Zeshan</dc:creator>

					<description>
						<![CDATA[
						<p>Hi Frank,</p>
<p>We&#8217;re sorry for the confusion! Selecting a category from &#8220;All Taxonomies&#8221; section will only enable the sidebar for that specific category page, it won&#8217;t be shown on the posts added to that category. </p>
<p>To show the category on certain posts, you need to select them under <strong>All Pages and Posts</strong> (see: <a href="http://prntscr.com/599be3" rel="nofollow">http://prntscr.com/599be3</a>).</p>
<p>Thanks!</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/create-sidebar-for-post-category/#post-195909</guid>
					<title><![CDATA[Reply To: Create Sidebar for Post Category]]></title>
					<link>https://theme.co/archive/forums/topic/create-sidebar-for-post-category/#post-195909</link>
					<pubDate>Sat, 31 Jan 2015 13:45:12 +0000</pubDate>
					<dc:creator>Nicolas Z</dc:creator>

					<description>
						<![CDATA[
						<p>Hi Support,</p>
<p>I need to do exactly that :</p>
<blockquote><p>Hi Frank,</p>
<p>You mean each post should have the sidebar assigned for each category?</p></blockquote>
<p>I tried your codes, but I have unfurtunately no sidebars on the posts, and my post content goes on the right side of the page.</p>
<p>I am on a ethos theme, but on a local installation for now.</p>
<p>Thanks for your help,</p>
<p>Best regards.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/create-sidebar-for-post-category/#post-196190</guid>
					<title><![CDATA[Reply To: Create Sidebar for Post Category]]></title>
					<link>https://theme.co/archive/forums/topic/create-sidebar-for-post-category/#post-196190</link>
					<pubDate>Sat, 31 Jan 2015 23:58:44 +0000</pubDate>
					<dc:creator>Rad</dc:creator>

					<description>
						<![CDATA[
						<p>@Frank,</p>
<p>As a follow up explanation. Sidebars that can be assigned from <strong>Admin &gt; Appearance &gt; Sidebars</strong> are displayable to where it&#8217;s assigned. The taxonomy selection will let you only assign a sidebar to specific taxonomy, like example, the category page (/category/music/) will have that sidebar, but not at the post that has music category.</p>
<blockquote><p>I’m attempting to create a new sidebar that shows for all posts within a specific category.</p></blockquote>
<p>As your initial request, you&#8217;re requesting for sidebar that shows for all posts within a specific category, then the provided customisation fits that. With that, the assigned sidebar for specific category will be the sidebar that will display to its posts (single post) too. So no need to assign sidebars one by one for each post.</p>
<p>If you now decided just to assign a sidebar to a certain category, then you can ignore the provided customisation. And you can use <strong>Admin &gt; Appearance &gt; Sidebars</strong> for that.</p>
<p>@Nicolaz, hmm I will need to do some testing at your end that. How about setting a live stage for testing? Have you check your layout if it&#8217;s allowed to have a sidebar? Have you created a sidebar at <strong>Admin &gt; Appearance &gt; Sidebar</strong> and assigned it at <strong>Admin &gt; Posts &gt; Categories</strong>?</p>
<p>here is another related thread,<br />
<a href="https://theme.co/x/member/forums/topic/portfolio-menu/page/2/#post-134727" rel="nofollow">https://theme.co/x/member/forums/topic/portfolio-menu/page/2/#post-134727</a> but for portfolio</p>
<p>here is the updated code, with cleaning</p>
<pre><code>function post_category_add_meta_field() {
  // this will add the custom meta field to the add new term page
  ?&gt;
  &lt;div class=&quot;form-field&quot;&gt;
    &lt;label for=&quot;term_meta[category-sidebar]&quot;&gt;&lt;?php _e( &#039;Item\&#039;s Sidebar&#039;, &#039;__x__&#039; ); ?&gt;&lt;/label&gt;
    &lt;select name=&quot;term_meta[category-sidebar]&quot; id=&quot;term_meta[category-sidebar]&quot;&gt;&lt;?php echo post_category_sidebar_options(); ?&gt;&lt;/select&gt;
    &lt;p class=&quot;description&quot;&gt;&lt;?php _e( &#039;Select Sidebar&#039;,&#039;__x__&#039; ); ?&gt;&lt;/p&gt;
  &lt;/div&gt;
&lt;?php
}

function post_category_edit_meta_field($term) {
 
  // put the term ID into a variable
  $t_id = $term-&gt;term_id;
 
  // retrieve the existing value(s) for this meta field. This returns an array
  $term_meta = get_option( &quot;taxonomy_$t_id&quot; ); ?&gt;
  &lt;tr class=&quot;form-field&quot;&gt;
  &lt;th scope=&quot;row&quot; valign=&quot;top&quot;&gt;&lt;label for=&quot;term_meta[category-sidebar]&quot;&gt;&lt;?php _e( &#039;Item\&#039;s Sidebar&#039;, &#039;__x__&#039; ); ?&gt;&lt;/label&gt;&lt;/th&gt;
    &lt;td&gt;
    &lt;select name=&quot;term_meta[category-sidebar]&quot; id=&quot;term_meta[category-sidebar]&quot;&gt;&lt;?php echo post_category_sidebar_options( $term_meta[&#039;category-sidebar&#039;] ); ?&gt;&lt;/select&gt;
      &lt;p class=&quot;description&quot;&gt;&lt;?php _e( &#039;Select Sidebar&#039;,&#039;__x__&#039; ); ?&gt;&lt;/p&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
&lt;?php
}

add_action( &#039;category_edit_form_fields&#039;, &#039;post_category_edit_meta_field&#039;, 10, 2 );
add_action( &#039;category_add_form_fields&#039;, &#039;post_category_add_meta_field&#039;, 10, 2 );

function save_post_category_custom_meta( $term_id ) {
  if ( isset( $_POST[&#039;term_meta&#039;] ) ) {
    $t_id = $term_id;
    $term_meta = get_option( &quot;taxonomy_$t_id&quot; );
    $cat_keys = array_keys( $_POST[&#039;term_meta&#039;] );
    foreach ( $cat_keys as $key ) {
      if ( isset ( $_POST[&#039;term_meta&#039;][$key] ) ) {
        $term_meta[$key] = $_POST[&#039;term_meta&#039;][$key];
      }
    }
    // Save the option array.
    update_option( &quot;taxonomy_$t_id&quot;, $term_meta );
  }
}  
add_action( &#039;edited_category&#039;, &#039;save_post_category_custom_meta&#039;, 10, 2 );  
add_action( &#039;create_category&#039;, &#039;save_post_category_custom_meta&#039;, 10, 2 );

function post_category_sidebar_options ( $default ) {
  $sidebars = get_option( &#039;ups_sidebars&#039; );
  $option = &#039;&lt;option value=&quot;sidebar-main&quot; &#039;.( !isset($default) || empty($default) || $default == &#039;sidebar-main&#039; ? &#039; selected &#039; : &#039;&#039; ).&#039;&gt;Default&lt;/option&gt;&#039;;
  foreach ( $sidebars as $id =&gt; $sidebar ) {
      $option .= &#039;&lt;option value=&quot;&#039;.$id.&#039;&quot; &#039;.( $id==$default ? &#039; selected &#039; : &#039;&#039; ).&#039;&gt;&#039;.$sidebar[&#039;name&#039;].&#039;&lt;/option&gt;&#039;;
  }
  return $option;
}
</code></pre>
<p>Code works on my end 🙂</p>
<p>Thanks!</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/create-sidebar-for-post-category/#post-196581</guid>
					<title><![CDATA[Reply To: Create Sidebar for Post Category]]></title>
					<link>https://theme.co/archive/forums/topic/create-sidebar-for-post-category/#post-196581</link>
					<pubDate>Sun, 01 Feb 2015 16:45:38 +0000</pubDate>
					<dc:creator>Nicolas Z</dc:creator>

					<description>
						<![CDATA[
						<p>Yes it&#8217;s working great ! Without the wp-single.php modifications !</p>
<p>Thanks support 🙂 !</p>
<p>Have a nice day.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>https://theme.co/archive/forums/topic/create-sidebar-for-post-category/#post-196815</guid>
					<title><![CDATA[Reply To: Create Sidebar for Post Category]]></title>
					<link>https://theme.co/archive/forums/topic/create-sidebar-for-post-category/#post-196815</link>
					<pubDate>Mon, 02 Feb 2015 03:52:31 +0000</pubDate>
					<dc:creator>Christian</dc:creator>

					<description>
						<![CDATA[
						<p>You&#8217;re welcome Nicolas.</p>
						]]>
					</description>

					
					
				</item>

					
		
	</channel>
	</rss>

