get all posts from a custom post type

You can use wp_query() for this to work $args = array( ‘post_type’ => ‘auction’, ‘posts_per_page’ => -1 ) $query = new WP_Query($args); if ($query->have_posts() ) : echo ‘<select>’; while ( $query->have_posts() ) : $query->the_post(); echo ‘<option value=”‘ . get_the_ID() . ‘”>’ . get_the_title() . ‘</option>’; endwhile; echo ‘</select>’; wp_reset_postdata(); endif; Documentation for WP_Query https://codex.wordpress.org/Class_Reference/WP_Query

Possible to change the URL for the regular post type without affecting the URL of other custom post types?

You could do this on custom post type registration. 1) Set your default permalink in the WordPress admin to your desired structure e.g.: /blog/%postname% 2) Add the “slug” and “with_front” parameter to the rewrite-array in the register_post_type function. “slug” must be the name of your post-type. $args = array( // … ‘rewrite’ => array( ‘slug’ … Read more

Using meta_query, how can i filter by a custom field and order by another one?

This seems to be a bug in WordPress. WordPress actually modifies the meta_query if you specify orderby and meta_key as query vars. Normally this modification adds the new meta_key as the first array in meta_query array and hence the orderby is applied to the first meta key specified in meta_query. But when you modify orderby, … Read more

WP_Query by a category id and a custom post_type

try this, it’s work for me. $args=array( ‘posts_per_page’ => 50, ‘post_type’ => ‘my_custom_type’ ‘cat’ => $cat_id, ); $wp_query = new WP_Query( $args ); Category Parameters cat (int): use category id. category_name (string): use category slug (NOT name). category__and (array): use category id. category__in (array): use category id. category__not_in (array): use category id.