Community Forums › Forums › Archived Forums › General Discussion › add custom sidebar to custom portfolio archive page
Tagged: add sidebar, custom portfolio archive
- This topic has 5 replies, 2 voices, and was last updated 10 years ago by 21pulse123.
-
AuthorPosts
-
April 19, 2014 at 12:57 pm #10130721pulse123Member
I have created a custom portfolio post type and this is the only portfolio in my site. There is no problem to assign specific sidebar to use as I have add the "sidebar selection" in the post option.
In the Archive page, i would like to add the "sidebar selection" so i can assign the sidebar created for this page. I am using simple sidebar to create custom sidebar for category/page.
I am using News Pro theme. Below are the code i used to create the portfolio post type in function.php I have spent few days to find out solution but failed .. I am not knowledgeable on php thus any help or guidance is really appreciated.
/ Create portfolio custom post type */
add_action( 'init', 'portfolio_post_type' );
function portfolio_post_type() {
register_post_type( 'portfolio',
array(
'labels' => array(
'name' => __( 'immigration' ),
'singular_name' => __( 'immigration' ),
),
'exclude_from_search' => true,
'has_archive' => true,
'hierarchical' => true,
'show_ui' => true,
'show_in_menu' => true,
'taxonomies' => array( 'post_tag' ),
'menu_icon' => get_stylesheet_directory_uri() . '/images/icons/portfolio.png',
'public' => true,
'rewrite' => array( 'slug' => 'immigration' ),
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes', 'genesis-seo', 'genesis-cpt-archives-settings','genesis-simple-sidebars'
),
)
);
}April 19, 2014 at 10:16 pm #101359essaysnarkParticipantLet me see if I am following you.
You've successfully initialized the sidebar, and it's showing up in your Widgets screen? And now you want to use it to display the portfolio CPTs somehow?
If I've understood you correctly, then I think there are two plugins that may help:
1. To display the portfolio CPTs, you should be able to use the Genesis Featured Widget Amplified plugin:
https://wordpress.org/plugins/genesis-featured-widget-amplified/
2. To have that widget operate only on the Archives page, then you can use the Widget Logic plugin
http://wordpress.org/plugins/widget-logic/
You will want to use a conditional like is_archive()
https://codex.wordpress.org/Function_Reference/is_archive
I may have misunderstood part or all of your request though. If so, please write back and explain it again and I'll give it another go.
April 20, 2014 at 5:14 am #10138321pulse123MemberThanks for your reply.
Yes i have created a sidebar showing up in the widget screen, but i do not know how to add it to the CPT "archive page". There is no problem to show custom sidebar in "CPT post" becoz there is a sidebar option in post edit. I would like to do the same in the CPT "archive page" as well ... can the widget logic plugin can work for that ?
April 20, 2014 at 9:14 am #101429essaysnarkParticipantThe suggestions I provided should cover this situation then. Did you try them?
April 20, 2014 at 4:46 pm #10154121pulse123MemberI have tried to add is_archive() but seems not working ...
April 20, 2014 at 7:27 pm #10156321pulse123Memberi have found a fix on this. i downloaded "custom sidebars" and it work on the theme and can create/assign sidebar.
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.