• I inherited a site with tons of custom coding, it’s just a jungle of confusion. There are many types of customs posts within the content.

    I updated the WP software, plugins, and theme. Now the pagination is missing from the pages that display custom post types. The pagination is working on the blog.

    I read through some posts and articles about paginating custom posts and my template code looks correct… I did try altering the pagination arguments without any change. I am also having a tough time just trying to insert some other php commands within this jumble, like just bolting on one of the page-navi plugins at the end of the loop.

    <?php
    /**
     *  Pigtronix TV Page Template
     */
    add_filter('genesis_pre_get_option_site_layout', 'wds_pig_single_layout');
    function wds_pig_single_layout($layout) {
        $layout = 'full-width-content';
        return $layout;
    }
    
    add_filter( 'excerpt_length', 'pig_vid_excerpt', 999 );
    function pig_vid_excerpt( $length ) {
    	return 10;
    }
    
    remove_action('genesis_after_endwhile', 'genesis_posts_nav');
    add_filter ( 'genesis_prev_link_text', 'pig_video_nav_text' );
    function pig_video_nav_text() {
    	return '&larr; Newer Videos';
    }
    add_filter ( 'genesis_next_link_text', 'video_nav_text2' );
    function video_nav_text2() {
    	return 'Older Videos &rarr;';
    }
    
    add_action('genesis_after_post_content', 'tv_page');
    function tv_page() {
    
    	$args = array(
    		'relation' => 'AND',
    		array(
    			'taxonomy' => 'featured-category',
    			'field' => 'slug',
    			'terms' => array( 'featured-video' ),
    		),
    		array(
    			'taxonomy' => 'featured-category',
    			'field' => 'slug',
    			'terms' => array( 'video-playlist', 'video-series' ),
    			'operator' => 'NOT IN'
    		)
    	);
    	$feat_vid_loop = new WP_Query( array(
    		'post_type' => 'video',
    		'posts_per_page' => 1,
    		'orderby' => 'menu_order',
    		'order' => 'ASC',
    		'tax_query' => $args,
    		)
    	);
    	$feat_id = '';
    	echo '<div id="featured-video">';
    	pig_video_loops( $feat_vid_loop, true );
    	echo '</div><!-- /#featured-video -->';
    
    	$args = array(
    		array(
    			'taxonomy' => 'featured-category',
    			'field' => 'slug',
    			'terms' => array( 'video-playlist', 'video-series' ),
    			'operator' => 'NOT IN'
    		)
    	);
    	global $wp_query;
    	$hold = $wp_query;
    	$paged = get_query_var('paged') ? absint( get_query_var('paged') ) : 1;
    	$wp_query = new WP_Query( array(
    		'post_type' => 'video',
    		'posts_per_page' => 16,
    		'orderby' => 'date',
    		'order' => 'DESC',
    		'tax_query' => $args,
    		'paged' => $paged,
    		'post__not_in' => array( $GLOBALS['pig_feat_video_id'] )
    		)
    	);
    	echo '<div id="media" class="highlight_wrap">';
    	pig_video_loops( $wp_query );
    
    	wds_prev_next_media_pagination_links( $wp_query );
    	$wp_query = $hold;
    
    	echo '</div><!-- /#media -->';
    
    }
    
    function pig_video_loops( $query=null, $feat=false ) {
    	if ( $query ) {
    
    		$counter = 1;
    		while ($query->have_posts()) : $query->the_post();
    
    		$thevideo = get_post_meta( get_the_id(), 'videobox', true );
    		$videourl = esc_attr( $thevideo );
    		// $featvideo = apply_filters( 'the_content', '[embed width="850" ]'. $videourl . '[/embed]' );
    		// $id = sanitize_html_class( get_the_ID() );
    		if ($feat) $vid_img = get_the_post_thumbnail( get_the_ID(), 'product-shot', array( 'class' => 'alignleft' ) );
    		else $vid_img = get_the_post_thumbnail( get_the_ID(), 'video-thumbnails' );
    		if ($feat) $GLOBALS['pig_feat_video_id'] = get_the_ID();
    		if ($counter % 2 == 0) { $class = ' class="last"'; } else { $class = ''; }
    		$imgclass = '';
    
    		if ($videourl) {
    			echo '<a'. $class .' href="'. get_permalink( ) .'" title="'. get_the_title( ) .'" alt="'. get_the_title( ) .'"><div class="highlight">';
    
    			if ( $vid_img ) {
    				echo '<span class="pig_image">';
    				echo '<div class="vid_play_arrow"></div>';
    				echo $vid_img;
    				echo '</span>';
    				$imgclass = ' image';
    			}
    			echo '<div class="item_info'. $imgclass .'">';
    					if ($feat) the_title( '<h2>', '</h2>' );
    					else the_title( '<h3>', '</h3>' );
    
    			the_category();
    
    			echo '</div>';
    
    			// 	echo $featvideo;
    			// echo '</div><!-- end #video-'. $id .' -->';
    
    		echo '</div></a>';
    		}
    		$counter++;
    		endwhile;
    		wp_reset_query();
    	}
    }
    
    genesis();
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter jjrocket

    (@jjrocket)

    Here is the relevant stuff from functions.php

    function wds_prev_next_media_pagination_links( $wp_query, $directory='' ) {
    	$page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    	$directory = ( $directory ) ? $directory : '/media/tv';
    	echo '<div id="media_nav">';
    	$max_page = $wp_query->max_num_pages;
    	$next_page = intval($page) - 1;
    	if( $next_page >= 1 )
    	  echo '<a class="nav_prev" href="' . get_previous_posts_page_link() . '">&laquo; Previous</a>';
    
    	for($i=1;$i<=$max_page;$i++) {
    	  if($page != $i)
    	    echo '&nbsp;<a href="' . site_url() . $directory .'/page/' . $i . '">' . $i . '</a>&nbsp;';
    	  else
    	    echo '&nbsp;<span class="nav_cur">' . $i . '</span>&nbsp;';
    
    	  if($i<$max_page)
    	    echo '|';
    	}
    
    	$max_page = $wp_query->max_num_pages;
    	$next_page = intval($page) + 1;
    
    	if( $next_page <= $max_page )
    	  echo '<a class="nav_next" href="' . get_next_posts_page_link() . '">Next &raquo;</a>';
    
    	echo '</div><!-- /#media_nav -->';
    	echo '<div class="clear"></div>';
    }
    Thread Starter jjrocket

    (@jjrocket)

    I was able to install the WP pagenavi plugin in the template and that is working.

    endwhile;
    		echo '<div class="navigation">';
    		wp_pagenavi();
    		echo '</div>';
    		wp_reset_query();

    Bizarrely, parts of the other pagination system are popping up around it.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Post Pagination disappeared after update’ is closed to new replies.