-
-
Save cdils/5152240 to your computer and use it in GitHub Desktop.
<?php | |
/** | |
* Template Name: Testimonial Archives | |
* Description: Used as a page template to show page contents, followed by a loop through a CPT archive | |
*/ | |
remove_action ('genesis_loop', 'genesis_do_loop'); // Remove the standard loop | |
add_action( 'genesis_loop', 'custom_do_grid_loop' ); // Add custom loop | |
function custom_do_grid_loop() { | |
// Intro Text (from page content) | |
echo '<div class="page hentry entry">'; | |
echo '<h1 class="entry-title">'. get_the_title() .'</h1>'; | |
echo '<div class="entry-content">' . get_the_content() ; | |
$args = array( | |
'post_type' => 'testimonials', // enter your custom post type | |
'orderby' => 'menu_order', | |
'order' => 'ASC', | |
'posts_per_page'=> '12', // overrides posts per page in theme settings | |
); | |
$loop = new WP_Query( $args ); | |
if( $loop->have_posts() ): | |
while( $loop->have_posts() ): $loop->the_post(); global $post; | |
echo '<div id="testimonials">'; | |
echo '<div class="one-fourth first">'; | |
echo '<div class="quote-obtuse"><div class="pic">'. get_the_post_thumbnail( $id, array(150,150) ).'</div></div>'; | |
echo '<div style="margin-top:20px;line-height:20px;text-align:right;"><cite>'.genesis_get_custom_field( '_cd_client_name' ).'</cite><br />'.genesis_get_custom_field( '_cd_client_title' ).'</div>'; | |
echo '</div>'; | |
echo '<div class="three-fourths" style="border-bottom:1px solid #DDD;">'; | |
echo '<h3>' . get_the_title() . '</h3>'; | |
echo '<blockquote><p>' . get_the_content() . '</p></blockquote>'; | |
echo '</div>'; | |
echo '</div>'; | |
endwhile; | |
endif; | |
// Outro Text (hard coded) | |
echo '<div class="call-to-action">Want me to make your next web project easier? <a href="http://www.carriedils.com/contact">Let\'s Talk</a></div>'; | |
echo '</div><!-- end .entry-content -->'; | |
echo '</div><!-- end .page .hentry .entry -->'; | |
} | |
/** Remove Post Info */ | |
remove_action('genesis_before_post_content','genesis_post_info'); | |
remove_action('genesis_after_post_content','genesis_post_meta'); | |
genesis(); |
Hi, I´ve seen your work at http://www.carriedils.com/, congratulations. I´ve tried to create an Archive Template for a Custom Post Type following your post, but I can´t do it.
I just want an Archive Template without any special thing: Just to show in a page from this template the posts from that CPT, like a blog Page, not grid, not special layout, just like a blog Page shows the posts. I´ve tried to get it in all the ways, but I can´t do it.
I pray that you can help to me, if you can tell me how must I write my archive.php content for my cpt, and then create a page with that template for just to show the posts that I´ve entered in this CPT.
Can you help me please?
Thank you very much. (and sorry for my English. And, by the way, beautifull smile)
Jaime
Sorry, another thing
I´ve done this archive.php, and the page, but I can´t get show just the excerpt, and that the title link to the single post, and I wish it to show the "read more...", the autor, the date, well, as I´ve told to you, just like a blog page.
Is this:
'; echo ''. get_the_title() .'
'; echo '' . get_the_title() . '
'; echo ''; echo '' . get_the_content() . '
Why you didn't put the wp_reset_postdata(); after your loop? But on the other article you have http://www.carriedils.com/custom-page-template-genesis/ you included it when you create a page template