0

Ok I'm using the plugin "The Cart Press" and I am trying to understand how multiple loops work when using a custom post type.

If I do a regular query for posts it just gives me back my blog posts and not my TCP products. When displaying products regularly they use the same loop functions as blog posts and so I'm wondering what is happening differently to cause these products to be loaded.

I have used a portfolio plugin in the past called "Simple Portfolio" which has a custom function called simple_portfolio_get_projects() which just gives me an array of projects and I would like to be able to do the same with TCP products.

  • The code you are using for the loops, especially the queries, would be useful. – fuxia Nov 6 '12 at 11:19
  • Currently I am just using the regular loop. It uses its own taxonomy www.example.com/product_category/category-slug to list the items and then www.example.com/product/product-slug for the product. But inside the page for a single product I want to be able to show all other products in the same category. – Jacob Tomlinson Nov 6 '12 at 11:27
1

I've managed to do it by setting the post type when I make the query

$my_query = new WP_Query( array("post_type" => "tcp_product"));
if ( $my_query->have_posts() ) { 
    while ( $my_query->have_posts() ) { 
        $my_query->the_post();
        the_title();
    }
}
wp_reset_postdata();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.