Solved

Pagination not working on custom post excerpts

Posted on 2014-01-13
6
361 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 34

Expert Comment

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

Author Comment

by:glepiza
Comment Utility
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 34

Expert Comment

by:gr8gonzo
Comment Utility
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

Accepted Solution

by:
glepiza earned 0 total points
Comment Utility
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 34

Expert Comment

by:gr8gonzo
Comment Utility
Glad to hear it!
0
 

Author Closing Comment

by:glepiza
Comment Utility
I found the answer.

Thanks.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now