コード例 #1
0
ファイル: functions.php プロジェクト: Netsoro/gdnlteamgroup
function evlsimilar_posts()
{
    $post = '';
    $orig_post = $post;
    global $post;
    $evloptions = get_option('evolve');
    if ($evloptions['evl_similar_posts'] == "category") {
        $matchby = get_the_category($post->ID);
        $matchin = 'category';
    } else {
        $matchby = wp_get_post_tags($post->ID);
        $matchin = 'tag';
    }
    if ($matchby) {
        $matchby_ids = array();
        foreach ($matchby as $individual_matchby) {
            $matchby_ids[] = $individual_matchby->term_id;
        }
        $args = array($matchin . '__in' => $matchby_ids, 'post__not_in' => array($post->ID), 'showposts' => 5, 'ignore_sticky_posts' => 1);
        $my_query = new wp_query($args);
        if ($my_query->have_posts()) {
            _e('<div style="padding:5px;margin-bottom:40px;"><h5 style="font-style:italic;">Similar posts</h5><ul style="margin-bottom:0px;">', 'evolve');
            while ($my_query->have_posts()) {
                $my_query->the_post();
                ?>
			<li style="padding-bottom:5px;">
      
     <a style="font-weight:bold;font-size:15px;" href="<?php 
                the_permalink();
                ?>
" rel="bookmark" title="Permanent Link to <?php 
                the_title();
                ?>
">
<?php 
                if (get_the_title()) {
                    $title = the_title('', '', false);
                    echo evltruncate($title, 40, '...');
                } else {
                    echo "Untitled";
                }
                ?>
</a>

  <?php 
                if (get_the_content()) {
                    ?>
 &mdash; <small style="font-style:italic;"><?php 
                    $postexcerpt = get_the_content();
                    $postexcerpt = apply_filters('the_content', $postexcerpt);
                    $postexcerpt = str_replace(']]>', ']]&gt;', $postexcerpt);
                    $postexcerpt = strip_tags($postexcerpt);
                    $postexcerpt = strip_shortcodes($postexcerpt);
                    echo evltruncate($postexcerpt, 60, '...');
                    ?>
</small> <?php 
                }
                ?>
      
      </li>
		<?php 
            }
            echo '</ul></div>';
        }
    }
    $post = $orig_post;
    wp_reset_query();
}
コード例 #2
0
                    echo '"><img src="' . $image . '" alt="';
                    the_title();
                    echo '" /></a>';
                }
            }
            ?>


<p>
<?php 
            $postexcerpt = get_the_content();
            $postexcerpt = apply_filters('the_content', $postexcerpt);
            $postexcerpt = str_replace(']]>', ']]&gt;', $postexcerpt);
            $postexcerpt = strip_tags($postexcerpt);
            $postexcerpt = strip_shortcodes($postexcerpt);
            echo evltruncate($postexcerpt, 180, ' [...]');
            ?>
 
</p> 
 
 
 





<a class="post-more" href="<?php 
            the_permalink();
            ?>
"><?php