Created
March 6, 2013 10:00
-
-
Save neocreo/5098224 to your computer and use it in GitHub Desktop.
WP: list latest from custom post types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php //list 3 latest of all content ?> | |
| <aside id="list_latest"> | |
| <?php //Activities ?> | |
| <h2><?php _e( 'Latest Activities', 'bonestheme' ); ?></h2> | |
| <?php $posts = new WP_Query(array( | |
| 'post_type' => 'neo_activities', | |
| // 'category_name' => 'arbetsprover', | |
| 'posts_per_page' => 3 | |
| )); ?> | |
| <ul class="image-list vertical"> | |
| <?php while ( $posts->have_posts() ) : $posts->the_post(); ?> | |
| <li id="activity-<?php the_ID(); ?>" <?php post_class(); ?>> | |
| <?php if ( has_post_thumbnail() ) { | |
| $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large'); | |
| //echo '<a href="' . $large_image_url[0] . '" title="' . get_the_title() . ' - ' . get_post_meta( $post->ID, 'neometa_activity-type', true ) . '" rel="lightbox">'; | |
| ?> | |
| <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"> | |
| <?php the_post_thumbnail('activity-medium'); ?> | |
| <span class="link_title"><?php the_title(); ?></span> | |
| <span class="link_readmore"><?php _e( 'Continue reading…', 'bonestheme' ); ?></span> | |
| </a> | |
| <?php } ?> | |
| </li> | |
| <?php endwhile; ?> | |
| <?php wp_reset_query(); ?> | |
| </ul> | |
| <p><a href="/activity/"><?php _e('More Activities','bonestheme') ?></a></p> | |
| <?php //Places ?> | |
| <h2><?php _e( 'Latest Places', 'bonestheme' ); ?></h2> | |
| <?php $posts = new WP_Query(array( | |
| 'post_type' => 'neo_places', | |
| // 'category_name' => 'arbetsprover', | |
| 'posts_per_page' => 3 | |
| )); ?> | |
| <ul class="image-list vertical"> | |
| <?php while ( $posts->have_posts() ) : $posts->the_post(); ?> | |
| <li id="place-<?php the_ID(); ?>" <?php post_class(); ?>> | |
| <?php if ( has_post_thumbnail() ) { | |
| $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large'); | |
| //echo '<a href="' . $large_image_url[0] . '" title="' . get_the_title() . ' - ' . get_post_meta( $post->ID, 'neometa_testimonial-type', true ) . '" rel="lightbox">'; | |
| the_post_thumbnail('place-medium'); | |
| echo '</a>'; | |
| } ?> | |
| <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"> | |
| <span class="link_title"><?php the_title(); ?></span> | |
| <span class="link_readmore"><?php _e( 'Continue reading…', 'bonestheme' ); ?></span> | |
| </a> | |
| </li> | |
| <?php endwhile; ?> | |
| <?php wp_reset_query(); ?> | |
| </ul> | |
| <p><a href="/place/"><?php _e('More Places','bonestheme') ?></a></p> | |
| <?php //News ?> | |
| <h2><?php _e( 'Latest News', 'bonestheme' ); ?></h2> | |
| <?php | |
| global $post; | |
| //$the_newest = get_posts('numberposts=5'); | |
| $post_args = array( | |
| 'post_type' => 'post', | |
| //'lang' => $curr_lang, | |
| 'numberposts' => 3 | |
| ); | |
| $the_newest = get_posts( $post_args ); | |
| //print_r($the_newest) ; | |
| //$the_newer = get_posts('numberposts=3&offset=1'); | |
| //$the_new = get_posts('numberposts=5&offset=4&order=DESC&orderby=post_date'); | |
| ?> | |
| <ul class="news-list"> | |
| <?php foreach($the_newest as $post) : | |
| setup_postdata($post); ?> | |
| <li id="news-<?php the_ID(); ?>"> | |
| <h4 class="newstitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h4> | |
| <? /*<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_post_thumbnail('news-small'); ?></a> */?> | |
| <?php the_excerpt(); ?> | |
| </li> | |
| <?php endforeach; ?> | |
| </ul> | |
| <p><a href="/activity/"><?php _e('More Articles','bonestheme') ?></a></p> | |
| </aside> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment