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
Solved

Pagination not working on custom post excerpts

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

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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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 34

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
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 add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
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…

789 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