Tagged: x
-
AuthorPosts
-
April 22, 2016 at 8:19 am #895335
nicomorganParticipantHI Guys
What I’m trying to achieve: Ethos home page (latest posts) does NOT show a sidebar. Clicking on a post shows a post page which shows a sidebar for the category that post is in. So, if I click on a post which is “news” it open and shows a sidebar specifically for the “news” category. The recent post by Adhawk talked about this and I want to achieve it.
For example, on a “news” post the sidebar would show other recent “news” posts – more relevant to that reader perhaps. On an “offers” post the sidebar would have the mailchimp signup form.
I’ve changed the default to content left, sidebar right in the customizer, then changed the Blog settings to be Full Width so that my Ethos home page does NOT show a sidebar. So far so good.
I then made the mistake lots of people have made in thinking that clicking “news” in taxonomy on my custom sidebar would achieve what I want.
I do NOT want to have to click on individual posts in that view to assign a sidebar, that’s ridiculous for a site with regular posts.
I found a thread here which involved adding a function to the child theme functions.php. This was supposed to add a new meta box on the posts > category page where I assigned a sidebar to a particular category. I then had to duplicate wp-single.php in my child them and change some code there too.
Perfect. Only it didn’t work. The post was two years old so it might not work with recent updates.
This seems to be an obvious development to me. How can I achieve this?
Thanks in advance.
April 23, 2016 at 12:56 am #896294
Rue NelModeratorHello There,
Thanks for writing in! Could please share the link of the topic? And To assist you better with this issue, would you mind providing us the url of your site with login credentials so we can take a closer look? 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 with everything.
To do this, you can make a post with the following info:
– Link to your site
– WordPress Admin username / passwordDon’t forget to select Set as private reply. This ensures your information is only visible to our staff.
Thank you.
April 23, 2016 at 4:09 am #896458
nicomorganParticipantThis reply has been marked as private.April 24, 2016 at 6:14 am #897335
ChristopherModeratorHi there,
Would you please provide us with URL of thread you’ve followed?
I checked your site and I see you’ve removed the function.Thanks.
April 24, 2016 at 7:09 am #897354
nicomorganParticipantYes, sorry. I wasn’t sure I wanted it there if it wasn’t doing what was suggested.
This is the forum thread: https://community.theme.co/forums/topic/create-sidebar-for-post-category/
I’m trying to do what Adhawk describe in the section “Sidebar Freedom” in this blog post: http://theme.co/blog/how-switching-to-x-theme-helped-us-double-traffic-boost-lead-generation-strengthen-our-brand/
Nico
April 25, 2016 at 1:17 am #898148
RadModeratorHi Nico,
The code that is provided in that thread should work at least for the version it’s integrated to. Please implement the code and please let me know. I’ll check its compatibility to your current version.
Oh, and please provide your FTP login credentials as well.
Thanks!
April 26, 2016 at 9:30 am #900439
nicomorganParticipantThis reply has been marked as private.April 27, 2016 at 7:25 am #901998
JackKeymasterHi there Nico,
Thanks for writing back!
I’ve been taking a look at this and it should work out the box with no changes and just using the custom sidebar.
As if you take a look at the ethos sidebar markup which is:
<?php if ( x_get_content_layout() != 'full-width' ) : ?> <aside class="<?php x_sidebar_class(); ?>" role="complementary"> <?php if ( get_option( 'ups_sidebars' ) != array() ) : ?> <?php dynamic_sidebar( apply_filters( 'ups_sidebar', 'sidebar-main' ) ); ?> <?php else : ?> <?php dynamic_sidebar( 'sidebar-main' ); ?> <?php endif; ?> </aside> <?php endif; ?>Here it’s calling ups_sidebar which should get the unique sidebar you have setup per page/post/taxonomy and then display/output any content within that sidebar, such as a posts widget etc.
I didn’t see any other modifications to the child theme, but can you try removing the modifications made to the child theme, then with your sidebar, set which widgets you want and then see what happens?
As if you check framework/functions/global/admin/sidebars.php this should work fine, which I’ve tested and verified it works on my development environment.
Thank you!
April 27, 2016 at 8:18 am #902103
nicomorganParticipantWhat I am not getting is that the new field is not showing when I edit a category. I’m expecting to go into Posts > categories and edit a category and have the option to add my custom sidebar to that category. Am I expecting the wrong thing?
As far as I can see the only changes I have made to my child theme functions.php are the ones for this change.
I did however change the:
<aside class=”x-sidebar left” role=”complementary”>
To:
<aside class=”x-sidebar right” role=”complementary”>
And:
<div class=”x-main right” role=”main”>
with
<div class=”x-main left” role=”main”>
In the code I copied to my child theme wp-single.php, because I want my sidebar on the right, not on the left. Could that have broken it?
I’ve even tried disabling a few plugins in case they could have been undoing what we have done but that hasn’t changed anything!
April 27, 2016 at 10:03 am #902353
nicomorganParticipantWhen I look at the output html on a “news” page, which should have the “news” sidebar I see that nothing has been output:
<aside class=”x-sidebar right” role=”complementary”>
</aside>
So this code:
<?php $terms = get_the_terms( get_the_ID(), 'category' ); if ( !isset( $terms ) && count( $terms ) == 0 ) $sidebar = 'sidebar-main'; else { $term = array_pop( $terms ); $setting = get_option( "taxonomy_".$term->term_id ); $sidebar = $setting['category-sidebar']; } dynamic_sidebar( $sidebar ); ?>Is not returning anything, not even the default sidebar.
April 27, 2016 at 10:06 am #902363
nicomorganParticipantI think I have it working now.
I don’t know what I changed but it suddenly started working. Possibly a caching issue, not that I’m using any!
Thank you!
April 27, 2016 at 4:48 pm #903091
JadeModeratorGlad to hear you got it sorted Nico. Cheers!
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-895335 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
