Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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,
    Chad

    #271670

    Hi 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,
    Peter

    #272198

    Why 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,
    Chad

    #273105

    Hi!

    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,
    Peter

    #378956

    I’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, 11 months ago by tpengelly.
    #379274

    Hey!

    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!
    Ismael

    #382195

    I got it to work, I forgot to set avia_term to my custom category.

    Is there away to create multiple instances of this widget?

    #384249

    Hi!

    The example on the link creates two different widget.

    Cheers!
    Ismael

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.