Solved

Pagination not working on custom post excerpts

Posted on 2014-01-13
6
383 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

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.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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…
The viewer will learn how to count occurrences of each item in an array.

707 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