예제 #1
0
파일: front.php 프로젝트: phupx/phamlook
										<?php 
            if (has_post_thumbnail()) {
                ?>
											<a href="<?php 
                the_permalink();
                ?>
" rel="bookmark">
												<?php 
                the_post_thumbnail('gomedia-carousel-thumb', array('class' => 'entry-thumb', 'alt' => esc_attr(get_the_title())));
                ?>
												<h2 class="entry-title"><?php 
                echo wp_trim_words(get_the_title(), 8);
                ?>
</h2>
												<?php 
                echo gomedia_get_post_format_icons();
                // get the post format icons.
                ?>
											</a>
										<?php 
            }
            ?>
									</article>
								</li>
							<?php 
        }
        ?>
						</ul>
					</div><!-- .jcarousel -->
					
					<?php 
예제 #2
0
 /**
  * Related posts.
  *
  * @since  1.0.0
  */
 function gomedia_related_posts()
 {
     global $post;
     // User selected to display the related posts or not.
     if (!of_get_option('gomedia_related', '1')) {
         return;
     }
     // Only display related posts on single page.
     if (!is_single()) {
         return;
     }
     // Get the taxonomy terms of the current page for the specified taxonomy.
     $terms = wp_get_post_terms($post->ID, 'category', array('fields' => 'ids'));
     // Check if the terms exist.
     if (empty($terms)) {
         return;
     }
     // Query arguments.
     $query = array('tax_query' => array(array('taxonomy' => 'category', 'field' => 'id', 'terms' => $terms, 'operator' => 'IN')), 'posts_per_page' => 4, 'exclude' => $post->ID, 'post_type' => 'post');
     // Allow plugins/themes developer to filter the default query.
     $query = apply_filters('gomedia_related_posts_query', $query);
     // Perform the query.
     $related = get_posts($query);
     if ($related) {
         $html = '<section class="related-posts">';
         $html .= '<h3 class="section-title">' . __('You might also like...', 'gomedia') . '</h3>';
         $html .= '<ul class="row">';
         foreach ($related as $post) {
             setup_postdata($post);
             $html .= '<li class="col-md-3">';
             $html .= '<a href="' . esc_url(get_permalink()) . '">';
             $html .= get_the_post_thumbnail($post->ID, 'gomedia-related-thumb', array('class' => 'entry-thumb', 'alt' => esc_attr(get_the_title())));
             $html .= '<h2 class="entry-title">' . get_the_title() . '</h2>';
             $html .= gomedia_get_post_format_icons();
             $html .= '</a>';
             $html .= '</li>';
         }
         $html .= '</ul>';
         $html .= '</section>';
     }
     // Restore original Post Data.
     wp_reset_postdata();
     if (isset($html)) {
         echo $html;
     }
 }