Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Pagination not working on custom post excerpts

Posted on 2014-01-13
6
Medium Priority
?
400 Views
Last Modified: 2014-01-23
Dear experts,

Could you please help me to know why the pagination I am applying to post excerpts is not working?

Any help would be greatly appreciated it.

function places_loop() {
    $loop = new WP_Query( array( 'post_type' => 'places', 'posts_per_page' => 4, 'paged' => get_query_var( 'paged' ) ) ); ?>
                <h1><?php the_title(); ?></h1>
            <div id="specials">
    <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
           
            <h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
            <div id="post-<?php the_ID(); ?>" class="places-list">
            <?php//use the genesis_get_custom_field template tag to display each custom field value ?>
            <h3><?php echo the_field('phone_number'); ?></h3>

            </div><!--end #specials -->
    <?php endwhile;?>
    <?php
    }
 
    genesis();


Thanks,

Winter
0
Comment
Question by:glepiza
  • 3
  • 3
6 Comments
 
LVL 35

Expert Comment

by:gr8gonzo
ID: 39777031
What's the output you're getting and what are you expecting?
0
 

Author Comment

by:glepiza
ID: 39777228
Thanks for answering my question.

Attached goes an screenshot as a reference. I am getting the post excerpts but I am not getting the pagination to go to the next post excerpts.

Thanks in advance,
pagination.jpg
0
 
LVL 35

Expert Comment

by:gr8gonzo
ID: 39777269
Pagination involves stopping the output so that only the content for a given page is shown, then giving the user the controls to select the next page. Once a user indicates what page they want next, the process repeats itself.

There isn't any code that I can see that would build out the user controls for pagination (unless "genesis()" is supposed to do it, but that's custom code, so you'd have to talk to whoever the original developer was).
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Accepted Solution

by:
glepiza earned 0 total points
ID: 39791627
ok, I found the answer in some genesis tutorials:

function be_custom_loop() {
      global $post;

      // arguments, adjust as needed
      $args = array(
            'post_type'      => 'places',
            'posts_per_page' => 2,
            'post_status'    => 'publish',
            'paged'          => get_query_var( 'paged' )
      );

      /*
      Overwrite $wp_query with our new query.
      The only reason we're doing this is so the pagination functions work,
      since they use $wp_query. If pagination wasn't an issue,
      use: https://gist.github.com/3218106
      */
      global $wp_query;
      $wp_query = new WP_Query( $args );

      if ( have_posts() ) :
            echo '<div>';
            while ( have_posts() ) : the_post();
                  echo '<h3><a href="' . get_permalink() . '"> ' . get_the_title() . ' </a> </h3>'; // show the title
0
 
LVL 35

Expert Comment

by:gr8gonzo
ID: 39791746
Glad to hear it!
0
 

Author Closing Comment

by:glepiza
ID: 39802543
I found the answer.

Thanks.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses
Course of the Month20 days, 23 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question