문제

I used the Custom Post Type UI Wordpress plugins to create a custom post type (Venues) and a custom taxonomy (Venue Type). I then created around 65 Venue items and tried to display them on the page using the following loop script. Unfortunately results are only limited to 10 Venue items per Venue type. Any ideas why?

        <?php 

          $args = array(
              'orderby' => 'name',
              'hide_empty' => true,
              'taxonomy' => 'venue_type'
          );
          $categories = get_categories($args);

          foreach( $categories as $category ) {
            echo '<div class="ui-accordion-header">';
              echo "<div>";
                echo "<h3>" . $category->name . "</h3>";
                echo "<p>" . $category->description . "</p>";
              echo "</div>";
            echo "</div>";
            $newargs = array(
             'post_type' => 'venue',
             'tax_query' => array(
              array(
               'taxonomy' => 'venue_type',
               'field' => 'slug',
               'terms' => $category->slug
              )
             )
            );

            echo '<div>';
              echo "<div>";
                echo '<ul class="cs-grid cs-style">';
                  query_posts( $newargs );
                  if (have_posts()) :
                      while (have_posts()) : the_post();
                        echo "<li>";
                          echo "<figure>";
                            the_post_thumbnail();  
                            echo "<figcaption>";    
                              echo "<h3>"; 
                                the_title(); 
                              echo "</h3>";
                              echo "<span>"; 
                                the_field('location');
                                echo " "; echo "|"; echo " ";
                                echo 'Capacity'; echo " "; the_field('capacity');
                              echo "</span>";
                            echo "</figcaption>";
                          echo "</figure>";  
                        echo "</li>";
                      endwhile;
                  endif;
                echo "</ul>";
              echo "</div>";
            echo "</div>";

          }

       ?>
도움이 되었습니까?

해결책

Have a look at the 'Settings -> Read' page in the Wordpress admin pages. There you can configure how many posts should be displayed per list page.

This blog post can also be useful: http://weblogs.about.com/od/wordpresstutorialstips/tp/How-To-Configure-Wordpress-Reading-Settings-For-Your-Blog.htm

Best of luck!

/Wille

다른 팁

This is probably happening because you have it set to only display 10 items a page. Adding 'posts_per_page' => -1, should work.

$newargs = array(
         'post_type' => 'venue',
         'tax_query' => array(
          array(
           'taxonomy' => 'venue_type',
           'field' => 'slug',
           'terms' => $category->slug
          )

would become

$newargs = array(
         'post_type' => 'venue',
         'tax_query' => array(
          array(
           'taxonomy' => 'venue_type',
           'field' => 'slug',
           'terms' => $category->slug,
            'posts_per_page' => -1
           )
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top