WordPress.org

Ready to get started?Download WordPress

Forums

Query_vars and custom post type wp_query (1 post)

  1. teolives
    Member
    Posted 1 year ago #

    Do you know why if I use this url with a variable:

    http://example.com/archive-tag-and-category/?post_type=my_post_type

    won't yield any result with the following code:

    $cust_post_query_var = get_query_var('post_type') ;
    $query = new WP_Query( array('post_type' =>  $cust_post_query_var)) ;

    whilst

    $query = new WP_Query( array('post_type' => $my_post_type)) ;

    works ok?

    I manage to retrieve the 'post_type' all right but WP_Query doesn't seem to like it...

Topic Closed

This topic has been closed to new replies.

About this Topic