-
AuthorPosts
-
May 29, 2014 at 8:13 am #271665
I know there’s a way to create a new widget using a single custom post type from the Enfold latest news widget.
Is there any way to modify the original widget function to query from all custom post types? Then I can simply select the necessary categories from within the widget to customize their use as needed.
Thanks,
ChadMay 29, 2014 at 8:30 am #271670Hi crschulz!
It depends on the cpts and taxonomies. If these post types use the same taxonomy you can query posts from multiple post types. If all (or some post types) use different taxonomies it’s not possible because our widget can just display the terms of one taxonomy.
Regards,
PeterMay 30, 2014 at 2:03 am #272198Why can’t this widget be made to function the same as the “blog post” element? If I choose the taxonomy “review” it will pull all posts that are classed as “review” from ALL cpts–or at least the cpts that I add to the loop.
But this widget will only pull “review” from the “post” post type. I was able to mod the combo widget to do exactly this, I’m just not sure how to recode the Latest News Widget.
Thanks,
ChadJune 2, 2014 at 7:36 am #273105Hi!
Yes, selecting taxonomies is currently not supported. You can use the code I posted here: https://kriesi.at/support/topic/latest-news-widget-show-custom-post-type/#post-239987 to register a new, custom widget for your cpt/taxonomy. If you want to query posts from several cpts which are grouped in the same taxonomy you can replace this line:
$this->avia_post_type = 'portfolio';
with
$this->avia_post_type = get_post_types();
– the get_post_types function will return all registered post types and WP will include all post types into the query.
If you want us to add this feature/advanced widget to the Enfold framework please submit a feature request here: https://kriesi.at/support/enfold-feature-requests/ and if your idea gets enough votes we’ll look into it.
Best regards,
PeterJanuary 13, 2015 at 5:57 pm #378956I’ve added the below code to my child functions.php but I can’t get my custom posts to display in the Latest CPT widget:
add_action(‘after_setup_theme’,’avia_load_additional_widget’);
function avia_load_additional_widget() {
// portfolio
if (!class_exists(‘avia_customcptbox_portfolio’)) {
class avia_customcptbox_portfolio extends avia_newsbox {
function avia_customcptbox_portfolio() {
$this->avia_term = ‘portfolio_entries’;
$this->avia_post_type = ‘portfolio’;
$this->avia_new_query = ”; //set a custom query here
$widget_ops = array(‘classname’ => ‘newsbox’, ‘description’ => ‘A Sidebar widget to display latest portfolio entries in your sidebar’ );$this->WP_Widget( ‘customcptbox_portfolio’, THEMENAME.’ Latest CPT Portfolio’, $widget_ops );
}
}
register_widget( ‘avia_customcptbox_portfolio’ );
}// post
if (!class_exists(‘avia_customcptbox_post’)) {
class avia_customcptbox_post extends avia_newsbox {
function avia_customcptbox_post() {
$this->avia_term = ‘category’;
$this->avia_post_type = ‘pressrelease’;
$this->avia_new_query = ”; //set a custom query here
$widget_ops = array(‘classname’ => ‘newsbox’, ‘description’ => ‘A Sidebar widget to display latest post entries in your sidebar’ );$this->WP_Widget( ‘customcptbox_post’, THEMENAME.’ Latest CPT Post’, $widget_ops );
}
}
register_widget( ‘avia_customcptbox_post’ );
}
}- This reply was modified 9 years, 10 months ago by tpengelly.
January 14, 2015 at 6:51 am #379274Hey!
What is the name of the new custom post type? Please try the code provided here: https://kriesi.at/support/topic/multiple-versions-of-latest-cpt-widget/#post-369273
Replace the $this->avia_post_type value.
Cheers!
IsmaelJanuary 20, 2015 at 12:18 am #382195I got it to work, I forgot to set avia_term to my custom category.
Is there away to create multiple instances of this widget?
January 23, 2015 at 9:23 am #384249 -
AuthorPosts
- You must be logged in to reply to this topic.