Beispiel #1
0
 function url_to_blog_card_tag($url)
 {
     if (!$url) {
         return;
     }
     $url = strip_tags($url);
     //URL
     $id = url_to_postid($url);
     //IDを取得(URLから投稿ID変換)
     if (!$id) {
         return;
     }
     //IDを取得できない場合はループを飛ばす
     global $post;
     $post_id = get_post($id);
     setup_postdata($post_id);
     $exce = $post_id->post_excerpt;
     $title = $post_id->post_title;
     //タイトルの取得
     $date = mysql2date('Y-m-d H:i', $post_id->post_date);
     //投稿日の取得
     $excerpt = get_content_excerpt($post_id->post_content, get_excerpt_length());
     //抜粋の取得
     if (is_wordpress_excerpt() && $exce) {
         //Wordpress固有の抜粋のとき
         $excerpt = $exce;
     }
     //新しいタブで開く場合
     $target = is_blog_card_target_blank() ? ' target="_blank"' : '';
     //$hatebu_url = preg_replace('/^https?:\/\//i', '', $url);
     //はてブを表示する場合
     $hatebu_tag = is_blog_card_hatena_visible() ? '<div class="blog-card-hatebu"><a href="//b.hatena.ne.jp/entry/' . $url . '"' . $target . '><img src="//b.hatena.ne.jp/entry/image/' . $url . '" alt="はてブ数" /></a></div>' : '';
     //サイトロゴを表示する場合
     $favicon_tag = '';
     if (is_favicon_enable() && get_the_favicon_url()) {
         //ファビコンが有効か確認
         //ファビコンをイメージたいのでそのまま表示する
         //$favicon_tag = '<span class="blog-card-favicon"><img src="'.get_the_favicon_url().'" class="blog-card-favicon-img" alt="ファビコン" /></span>';
         //はてなファビコンAPIを利用する
         //$favicon_tag = '<span class="blog-card-favicon"><img src="http://favicon.st-hatena.com/?url='.site_url().'" class="blog-card-favicon-img" alt="ファビコン" /></span>';
         //GoogleファビコンAPIを利用する
         //http://www.google.com/s2/favicons?domain=nelog.jp
         $favicon_tag = '<span class="blog-card-favicon"><img src="http://www.google.com/s2/favicons?domain=' . get_this_site_domain() . '" class="blog-card-favicon-img" alt="ファビコン" /></span>';
     }
     $site_logo_tag = is_blog_card_site_logo_visible() ? '<div class="blog-card-site">' . $favicon_tag . '<a href="' . home_url() . '"' . $target . '>' . get_this_site_domain() . '</a></div>' : '';
     $date_tag = '';
     if (is_blog_card_date_visible()) {
         $date_tag = '<div class="blog-card-date">' . $date . '</div>';
     }
     //サムネイルの取得(要100×100のサムネイル設定)
     $thumbnail = get_the_post_thumbnail($id, 'thumb100', array('class' => 'blog-card-thumb-image', 'alt' => $title));
     if (!$thumbnail) {
         //サムネイルが存在しない場合
         $thumbnail = '<img src="' . get_template_directory_uri() . '/images/no-image.png" alt="' . $title . '" class="blog-card-thumb-image" />';
     }
     //取得した情報からブログカードのHTMLタグを作成
     $tag = '<div class="blog-card internal-blog-card"><div class="blog-card-thumbnail"><a href="' . $url . '" class="blog-card-thumbnail-link"' . $target . '>' . $thumbnail . '</a></div><div class="blog-card-content"><div class="blog-card-title"><a href="' . $url . '" class="blog-card-title-link"' . $target . '>' . $title . '</a></div><div class="blog-card-excerpt">' . $excerpt . '</div></div><div class="blog-card-footer">' . $site_logo_tag . $hatebu_tag . $date_tag . '</div></div>';
     return $tag;
 }
            <a href="<?php 
        the_permalink();
        ?>
" class="related-entry-title-link" title="<?php 
        the_title();
        ?>
">
            <?php 
        the_title();
        //記事のタイトル
        ?>
            </a></h3>
        </header>
        <p class="related-entry-snippet">
       <?php 
        echo get_the_custom_excerpt($post->post_content, get_excerpt_length()) . '';
        //カスタマイズで指定した文字の長さだけ本文抜粋
        ?>
</p>

        <?php 
        if (get_theme_text_read_entry()) {
            //「記事を読む」のようなテキストが設定されている時
            ?>
        <footer>
          <p class="related-entry-read"><a href="<?php 
            the_permalink();
            ?>
"><?php 
            echo get_theme_text_read_entry();
            //デフォルト:記事を読む
    echo get_the_permalink() . $comment_count_anchor;
    ?>
" class="comment-count-link"><?php 
    echo get_comments_number();
    ?>
</a>
          </span>
        </span>
      <?php 
}
?>

    </p><!-- /.post-meta -->
  </header>
  <p class="entry-snippet"><?php 
echo get_the_custom_excerpt(get_the_content(''), get_excerpt_length());
//カスタマイズで指定した文字の長さだけ本文抜粋
?>
</p>

  <?php 
if (get_theme_text_read_entry()) {
    //「記事を読む」のようなテキストが設定されている時
    ?>
  <footer>
    <p class="entry-read"><a href="<?php 
    the_permalink();
    ?>
" class="entry-read-link"><?php 
    echo get_theme_text_read_entry();
    //記事を読む
Beispiel #4
0
function custom_excerpt_length()
{
    return intval(get_excerpt_length());
}