-
Author
Tagged: custom sidebar, CPT sidebar
-
April 10, 2015 at 14:49 #53908ImGParticipant
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?April 10, 2015 at 19:33 #53939sharmstrModeratorI dont think that code will work since Kleo has its own sidebar generator. Ty something like this. Put this in your functions file.
COPY CODEadd_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 solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
April 11, 2015 at 08:33 #54004ImGParticipantThamks @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!
April 11, 2015 at 16:07 #54025sharmstrModeratorTry 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 solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
-
AuthorPosts
The forum ‘KLEO’ is closed to new topics and replies.