• Resolved Netzialist

    (@netzialist)


    Hallo, Martin,
    gibt es irgendeinen Trick, dass das Widget auch mit einem CPT funktioniert?
    Der CPT teilt sich die Kategorien mit den Posts, aber das Widget beisst nicht rein, der Platz bleibt leer.

    Any chance to get the widget working together with custom post types as well?
    The CPT shares its categories with the posts, but the widget remains empty, nothing shows up.

    https://ww.wp.xz.cn/plugins/recent-posts-widget-with-thumbnails/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Martin Stehle

    (@hinjiriyo)

    Hallo Kirsten, ja, mit dem Hook ‘widget_posts_args’ kannst du die Query-Parameter für CPTs ändern.

    Yes, you can alter the query parameters for CPTs with the Hook ‘widget_posts_args’.

    function netzialist_get_cpt ( $query_args ) {
        // display standard posts and posts of a certain CPT
        $query_args[ 'post_type' ] = array( 'post', 'name/slug of the CPT' );
        return $query_args;
    }
    add_filter( 'widget_posts_args', 'netzialist_get_cpt' );

    More parameters in this document: https://codex.ww.wp.xz.cn/Class_Reference/WP_Query

    Thread Starter Netzialist

    (@netzialist)

    Danke!
    Da hätte ich selbst drauf kommen können wäre geschwindelt, ich wäre nämlich nicht drauf gekommen.

    Thanks so much!
    Sounds easy, but I have to admit, I had no clue.
    ;o)

    Plugin Contributor Martin Stehle

    (@hinjiriyo)

    Kirsten, would you please do me a favour and test that? I am afraid that hook is too general. It would not only change the query for the widget, but also the query for archive pages. Right? (I am thinking about renaming that and other hooks of the plugin to avoid interferences in other queries.)

    Thread Starter Netzialist

    (@netzialist)

    I see.
    It’s working fine for me.
    I have some 404 issues with the url to the category archive which I don’t quite understand. But I don’t think there is a relation to the filter – the issue appears anyway, filter active or not.

    Plugin Contributor Martin Stehle

    (@hinjiriyo)

    Thank you!

    Plugin Contributor Martin Stehle

    (@hinjiriyo)

    In the new plugin Ultimate Post List Pro you can list CPTs. And much more 🙂 You can play around with the free version “Ultimage Post List”, available here in the WP plugin directory.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Custom Post Types’ is closed to new replies.