Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Template Name: Adverts Archive
- See http://schema.org/Product for details of itemprop classifications
- */
- // Add a link after excerpt to read the ad
- add_filter( 'excerpt_more', 'new_excerpt_more' );
- function new_excerpt_more( $more ) {
- return '<p><b><a class="read-more" href="'. get_permalink( get_the_ID() ) . '">~ Read the Ad ~</a></b></p>';
- }
- add_filter('genesis_pre_get_option_site_layout', '__genesis_return_full_width_content');
- remove_action('genesis_loop', 'genesis_do_loop');
- add_action('genesis_loop', 'vm_custom_adverts_archive_loop');
- function vm_custom_adverts_archive_loop() {
- //global $paged;
- $paged = ( get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
- $args = array(
- 'posts_per_page' => 3,
- 'post_type' => 'adverts',
- 'paged' => $paged,
- 'orderby' => 'date',
- 'order' => 'DESC'
- );
- global $vm_query;
- $vm_query = new WP_Query ( $args );
- if ($vm_query->have_posts()) : // custom query for primary post content
- while ($vm_query->have_posts()) : $vm_query->the_post(); /*$do_not_duplicate = $post->ID;*/
- global $paged;
- $total_pages = $vm_query->max_num_pages;
- $postID = get_queried_object()->ID;
- $thePostID = get_the_ID();
- $postTitle = get_the_title($postID);
- $postThumb = ( get_post_meta($thePostID, '_vm_adThumb1', true) ); ?>
- <div itemscope itemtype="http://schema.org/Service">
- <?php echo '<h2><a href="'. get_permalink($post->$postID) .'"><span itemprop="name">' . $postTitle .'</span></a></h2>'; ?>
- <div class="adCopy entry">
- <?php
- echo '<div class="entry-content" itemprop="serviceType">'; // echo out schema property
- echo '<div class="one-fifth first"><a href="' . $postThumb . '" rel="lightbox"><img height="150" width="150" itemprop="image" alt="'.$postTitle.'" class="alignleft post-image entry-image" src="' . $postThumb . '"/></a></div>';
- echo '<div class="four-fifths last">'.( wpautop (the_excerpt()) ).'</div>'; // using post content as song description, preserve paragraphs with wpautop
- echo '</div>';
- ?>
- </div>
- </div><!-- end Item Scope -->
- <?php
- endwhile;
- // Ref Link: http://wp.tutsplus.com/tutorials/wordpress-pagination-a-primer/
- // Ref link: http://codex.wordpress.org/Function_Reference/paginate_links
- $big = 999999999; // need an unlikely integer
- echo paginate_links( array(
- 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
- 'format' => '?paged=%#%',
- 'current' => max( 1, get_query_var('paged') ),
- 'total' => $vm_query->max_num_pages
- ) );
- do_action( 'genesis_after_endwhile' );
- endif;
- wp_reset_query();
- }
- genesis(); // <- everything important: make sure to include this.
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement