0

Having custom post types with taxonomies.

Lets say I have a custom post type "Products" with taxonomies "new", "old", "fashion".

Now I have a Nav where I can click on wordpress.private/products/new/ but I always get a 404 page and seems like it's not even calling index.php file.

How can I get all those posts ?

0

You could try this way.

Create a new page called say 'All products' and apply the following template to it.

Here is the code for that should be used in your template, just above the while loop.

   $type = 'products';
   $args=array(
  'post_type' => $type,
  'post_status' => 'publish',
  'posts_per_page' => -1,
  'caller_get_posts'=> 1

  query_posts($args);

A complete sample template will be like below.

<?php
/**
 * Template Name: Page of Products
 *
 * Selectable from a dropdown menu on the edit page screen.
 */
?>

<?php get_header(); ?>

        <div id="container">
            <div id="content">

<?php
$type = 'products';
$args=array(
  'post_type' => $type,
  'post_status' => 'publish',
  'posts_per_page' => -1,
  'caller_get_posts'=> 1


query_posts($args);

if( have_posts() ) {
  while (have_posts()) : the_post(); ?>
    <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
    <?php
  endwhile;
}
wp_reset_query();  // Restore global post data stomped by the_post().
?>
            </div><!-- #content -->
        </div><!-- #container -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

It is not necessary that this is exact structure of your template. You may need to modify accordingly. But the logic is here.

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.