Community Forums › Forums › Archived Forums › General Discussion › Featured Custom Post Type Widget
- This topic has 7 replies, 2 voices, and was last updated 10 years, 11 months ago by essaysnark.
-
AuthorPosts
-
May 1, 2013 at 4:58 am #38718marjwyattMember
I would truly appreciate another set of eyes on this problem and hopefully a point in the right direction to solve it.
I'm customizing the Modern Portfolio theme for a site that uses custom post types with custom post type categories. The Custom Post Type (CPT) taxonomy has been declared as shown below:
`register_taxonomy( 'portfolio-type', array('portfolio'),
array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
));`That code is working and properly assigning categories to the custom post types.
Genesis has a core widget called a Featured Post Widget. The code for that widget is here: http://pastebin.com/0jk5yM4g
I leveraged that code to allow displays of CPTs as featured posts in the theme's home page portfolio area. That code is here: http://pastebin.com/jdZcffvM
I referenced this Codex post to make my changes:
http://codex.wordpress.org/Function_Reference/wp_dropdown_categoriesMy customized widget is in the child theme's folder structure so I have not modified Genesis Core code. I've added CSS to the theme to support the display in the same way the core Genesis Widget does and that is working perfectly.
The widget shows the CPT categories in my customized widget and saves them but it doesn't display the CPT category that has been chosen on the home page which is puzzling me. This development is due for delivery at the end of this week so I'm hoping that someone can offer a solution or tell me why this isn't working as expected. I'm out of ideas.
I am developing locally so the site isn't online anywhere.
Virtually Marj Wyatt
VirtuallyMarj.com | Twitter | Facebook | Google +May 1, 2013 at 5:25 pm #38843essaysnarkParticipantI'm totally dodging your actual question here, but possibly this plugin could do what you need?
May 1, 2013 at 9:08 pm #38870marjwyattMemberIt might, if I could select anything other than post from the dropdown.
I'll look at the plugin code and see if I can reverse engineer it for my purposes. Thanks.
Virtually Marj Wyatt
VirtuallyMarj.com | Twitter | Facebook | Google +May 1, 2013 at 9:20 pm #38871essaysnarkParticipantThat plugin supports CPTs and custom taxonomies, It's specifically for Genesis. I don't see why it wouldn't work.
May 1, 2013 at 9:39 pm #38872marjwyattMemberI had great hopes that it would but, when I loaded the widget, any attempt to chose another post type failed from the dropdown. You could install it and try for yourself.
The plugin hasn't been updated in nearly a year. It could be that a WP update has affected its functionality.
Virtually Marj Wyatt
VirtuallyMarj.com | Twitter | Facebook | Google +May 1, 2013 at 10:35 pm #38875essaysnarkParticipantStrange. The plugin works great for me, we have a gazillion CPTs and custom taxonomies and they all display fine in the respective dropdowns in the widget. Maybe whatever is preventing that from working is the same thing that prevented your custom code from working.
May 1, 2013 at 11:23 pm #38877marjwyattMemberNope ... not my code. In the downloaded plugin, this was at the top:
`
function __construct() {$this->defaults = array(
'count' => 0,
'title' => '',
'post_type' => 'post',
'page_id' => '',
'posts_term' => '',
'exclude_terms' => '',
'exclude_cat' => '',
'include_exclude' => '',
'post_id' => '',
'posts_num' => 1,
'posts_offset' => 0,
'orderby' => '',
'order' => '',
'meta_key' => '',
'show_sticky' => '',
'paged' => '',
'show_paged' => '',
'post_align' => '',
'show_image' => 0,
'link_image' => 1,
'image_position' => 'before-title',
'image_alignment' => '',
'image_size' => '',
'link_image_field' => '',
'show_gravatar' => 0,
'gravatar_alignment' => '',
'gravatar_size' => '',
'link_gravatar' => 0,
'show_title' => 0,
'link_title' => 1,
'link_title_field' => '',
'title_limit' => '',
'title_cutoff' => '…',
'show_byline' => 0,
'post_info' => '[post_date] ' . __( 'By', 'gfwa' ) . ' [post_author_posts_link] [post_comments]',
'show_content' => 'excerpt',
'show_archive_line' => 0,
'archive_link' => '',
'post_meta' => '[post_categories] [post_tags]',
'content_limit' => '',
'more_text' => __( '[Read More...]', 'gfwa' ),
'extra_posts' => '',
'extra_num' => '',
'extra_title' => '',
'extra_format' => 'ul',
'more_from_category' => '',
'more_from_category_text' => __( 'More Posts from this Taxonomy', 'gfwa' ),
'custom_field' => ''
);I changed this line of code
downloaded code: `'post_type' => 'post',`
revised code: `'post_type' => '',`It now works, with all my customizations in place.
Thanks for "forcing" me to look at it again. (smile) Now I can move forward.
Virtually Marj Wyatt
VirtuallyMarj.com | Twitter | Facebook | Google +May 2, 2013 at 9:16 am #38928essaysnarkParticipantAwesome - glad you figured it out!
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.