Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FUNCTIONS.PHP
- function awesome_excerpt($text, $raw_excerpt) {
- if( ! $raw_excerpt ) {
- $content = apply_filters( 'the_content', get_the_content() );
- $text = substr( $content, 0, strpos( $content, '</p>' ) + 4 );
- }
- $text = preg_replace("/<img[^>]+\>/i", "", $text);
- return $text;
- }
- add_filter( 'wp_trim_excerpt', 'awesome_excerpt', 10, 2 );
- -------------------------------------------------------------------------------------------------------
- CONTENT-RECENT-POSTS.PHP, using get_template to pull it into two template files SINGLE.PHP and FRONT-PAGE.PHP
- <?php
- if ( is_single()) {
- $categories = get_the_category();
- if ($categories) {
- foreach ($categories as $category) {
- $cat = $category->cat_ID;
- $args=array(
- 'cat' => $cat,
- 'order' => 'DESC',
- 'post__not_in' => array($post->ID),
- 'posts_per_page'=>2,
- 'caller_get_posts'=>1
- );
- $my_query = null;
- $my_query = new WP_Query($args);
- if( $my_query->have_posts() ) {
- while ($my_query->have_posts()) : $my_query->the_post();
- ?>
- <div class="col-md-6">
- <div class="recent-blog-post-item">
- <?php if(has_post_thumbnail()) : ?>
- <div class="blog-post-featured-img">
- <a href="<?php the_permalink(); ?>">
- <?php the_post_thumbnail(); ?>
- </a>
- </div>
- <?php endif; ?>
- <div class="blog-post-content recent-meta-text">
- <div class="recent-meta-title">
- <a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>">
- <h4><?php the_title(); ?></h4>
- </a>
- </div>
- <div class="recent-meta-excerpt">
- <?php the_excerpt(); ?>
- <a class="read-more" href="<?php the_permalink(); ?>">Read More <i class="fa fa-long-arrow-right"></i></a>
- </div>
- </div> <!-- end recent meta text -->
- </div><!-- end recent blog post item -->
- </div>
- <?php
- endwhile;
- }
- }
- } wp_reset_query();
- } else if(is_front_page()) {
- $args = array(
- 'order' => DESC,
- 'orderby' => 'date',
- 'posts_per_page'=>3,
- 'post_type' => 'post',
- 'caller_get_posts'=>1
- );
- $my_query = new WP_Query($args);
- if( $my_query->have_posts() ) {
- while ($my_query->have_posts()) : $my_query->the_post();
- ?>
- <div class="col-md-4">
- <div class="recent-blog-post-item">
- <?php if(has_post_thumbnail()) : ?>
- <div class="blog-post-featured-img">
- <a href="<?php the_permalink(); ?>">
- <?php the_post_thumbnail(); ?>
- </a>
- </div>
- <?php endif; ?>
- <div class="blog-post-content recent-meta-text">
- <div class="recent-meta-title">
- <a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>">
- <h4><?php the_title(); ?></h4>
- </a>
- </div>
- <div class="recent-meta-excerpt">
- <?php the_excerpt(); ?>
- <a class="read-more" href="<?php the_permalink(); ?>">Read More <i class="fa fa-long-arrow-right"></i></a>
- </div>
- </div> <!-- end recent meta text -->
- </div><!-- end recent blog post item -->
- </div>
- <?php
- endwhile;
- }
- }
- wp_reset_query();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement