This topic has 3 replies, 2 voices, and was last updated 9 years by sharmstr.

  • Author
  • #53908
     ImG
    Participant

    I have created sidebar by simply entering the sidebar name in the sidebars section, now i want to integrate that sidebar only for custom post type called “wiki” without any plugin, i have referred some codes in this page, but i don’t what to edit for my requirement, here are the codes which i have copied from that page to call already created sidebar `add_action(‘get_header’,’cd_change_genesis_sidebar’);
    function cd_change_genesis_sidebar() {
    if ( is_singular(‘jobs’)) { // Check if we’re on a single post for my CPT called “jobs”
    remove_action( ‘genesis_sidebar’, ‘genesis_do_sidebar’ ); //remove the default genesis sidebar
    add_action( ‘genesis_sidebar’, ‘cd_do_sidebar’ ); //add an action hook to call the function for my custom sidebar
    }
    }

    //Function to output my custom sidebar
    function cd_do_sidebar() {
    dynamic_sidebar( ‘job-single-sidebar’ );
    }`
    All i know is that sidebar name and its css class name, now what to edit in this code to get my requirement?

    #53939
     sharmstr
    Moderator

    I dont think that code will work since Kleo has its own sidebar generator. Ty something like this. Put this in your functions file.

    COPY CODE
    
    
    add_filter('kleo_sidebar_name','my_cpt_sidebar');
    function my_cpt_sidebar() {
    if (get_post_type( get_the_ID() ) == 'wiki') {
    	return 'wiki';
    	}
    }
    
    
    

    This assumes your cpt AND your sidebar are named wiki

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #54004
     ImG
    Participant

    Thamks @sharmstr, it works, these six lines of codes avoids me to install another plugin in my site as i have already installed to many plugins, but i have the same sidebar for Wiki single cpt,wiki categories,wiki archives, wiki tags. What modification i have to do in the given code for having individual sidebars for wiki archives,wiki categories, wiki tags. Any solution!

    #54025
     sharmstr
    Moderator

    Try to sort it yourself. Google how to check to see if you are on one of the other pages. I’ve given you the basic structure, now see if you can expand on it. Its how I learned and its what I’d do to answer your question.

    I’ll figure it out for you if you fail to figure it out.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

Viewing 4 posts - 1 through 4 (of 4 total)

The forum ‘KLEO’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?