Get related custom post by specifics custom post ID

I do it with that but i don’t think this is so optimized! function list_formation(){ $args = array(, ‘post_type’ => ‘categories’, ‘posts_per_page’ => 20, ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); $formations = get_posts(array( ‘post_type’ => ‘formations’, ‘post__in’ => array(16061), ‘meta_query’ => array( array( ‘key’ => ‘categories’, // name … Read more

Why are custom taxonomies only appearing on the edit page of one of these types, but not the other?

In short, it’s because your Formats taxonomy is not enabled in the REST API. Events shows both custom taxonomies and the built-in Categories, Resources only the built-in. That is actually the expected behavior. The Events post type doesn’t have the editor support, i.e. $supports = array(‘title’, ‘featured-image’, ‘thumbnail’, ‘excerpt’); — no editor in the list. … Read more

Different number posts per page based on custom post type term id

You can achieve it with pre_get_posts. With your current code there are multiple syntax errors. You have write it this way add_filter(‘pre_get_posts’, ‘limit_change_posts_archive’); function limit_change_posts_archive($query){ if ( !is_admin() && $query->is_main_query() && is_archive() && is_tax( ‘pdsh_categories’ ) && is_term( 1858 )) { $query->set(‘posts_per_page’, -1); } return $query; } As is_term is deprecated a different approach can … Read more