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
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)
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.)
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.
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.