Support » Fixing WordPress » Automatic pagination on Posts page that pulls/organizes posts by Custom Fields?

  • Hi. (First of all, I am looking for some quick help, but also am willing to hire someone to implement this custom solution)

    MichaelH had been kind enough to successfully help me with version 1 of this challenge, which was getting posts to be sorted/displayed alphabetically depending on one of the post’s Custom Field value.

    • My Posts page has been set to a static Page (Artists).
    • I have edited index.php and used an array and WP_Query to grab, order, and post my entries, based on a Custom Field Value

    I am now hoping someone can help me (or I can hire someone? – is there a board to post for that?) with pagination.

    What I am trying to do
    Take all the posts (that have been organized alphabetically by Custom Field Value), and display only 5 entries per page, with a link at the bottom that leads to the (dynamically created)next page of 5 entries, and so on, until all posts have been displayed.

    Here is the code I am currently using (minus div and header tags):

      'orderby' => 'meta_value',
      'meta_key' => 'ArtistLastName',
      'order' => 'ASC',
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => 5,
      'caller_get_posts'=> 1
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
       			<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    				<?php the_title(); ?>
                         <?php the_content();?>
    				<?	echo get_post_meta($post->ID, Bio, true);?>
    wp_reset_query();  // Restore global post data stomped by the_post().
    			<?php next_posts_link('&laquo; Older Entries') ?>

    EDIT: here is the link to the page where I use an array and WP Query to Alphabetize my posts based on a Custom Field value

Viewing 1 replies (of 1 total)
  • NOTE:
    sample code above has 'posts_per_page' => 5 as I only want 5 posts per page, but on the actual site the code is temporarily set to 'posts_per_page' => 11 until the solution is found.

Viewing 1 replies (of 1 total)
  • The topic ‘Automatic pagination on Posts page that pulls/organizes posts by Custom Fields?’ is closed to new replies.