When creating a post how do you select the format?

As post_format is a custom taxonomy and the different formats terms, you should be able to use the tax_input parameter in the new post args array to set the format. Something along these lines, $new_post_args = array(); // e.g. $format_slug = ‘gallery’; $valid_formats = get_post_format_slugs(); if ( ‘standard’ !== $format_slug && in_array( $format_slug, $valid_formats ) … Read more

How to get subcategories from category slug?

You may use get_term_children() to get children of a term but it return only ids so you could use get_term_by() to convert it to id Approach 3 This method is based WP builtin on get_term_children() and _get_term_hierarchy() but converted to support slug. The whole set of functions are presented here for reference. Like builtin version, … Read more

First x post with another template then the others

It shows more than 3 posts because you used post_per_page when it should be posts_per_page (note the plural “posts”). But actually, you can use the same query and use a counter to display the different template parts: $loop = new WP_Query( array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 5, ) ); $c = 1; // post … Read more

How to WP_Query() from multiple blogs and order them?

You can’t switch in different blogs of the network with the switch_to_blog([1,2]); function. The function needs a clearly integer value for one blog, see documentation. WP Core This process should help you. A custom way with the help of the WP core. // The sites IDs $sitesObj = get_sites([ ‘site__in’ => [1, 2,] ]); // … Read more