honeycreate
フォーラムへの返信
-
フォーラム: 使い方全般
返信が含まれるトピック: the_excerpt();の文字数を変更したい有料のテーマなのにお答えいただきありがとうございました。
またお返事が遅くなり、大変失礼しました。functionが絡むファイルは難しいんですね。。
結局moreタグで対処することとしました。
細かい部分まで設定したかったらやはり一から作らないとですね。
ありがとうございました!!
フォーラム: 使い方全般
返信が含まれるトピック: the_excerpt();の文字数を変更したい追記です
incフォルダの中にある
custom-functions.phpというファイルの中に
以下の記述を見つけました。function latestpostsoutput_func( $atts ){ extract( shortcode_atts( array( 'show' => '', ), $atts ) ); $postoutput = ''; wp_reset_query(); $n = 0; query_posts( array( 'posts_per_page'=>$show, 'post__not_in' => get_option('sticky_posts') ) ); if ( have_posts() ) : while ( have_posts() ) : the_post(); $n++; if( $n%3==0 ) $nomgn = 'last'; else $nomgn = ' '; if ( has_post_thumbnail()) { $large_imgSrc = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large'); $imgUrl = $large_imgSrc[0]; }else{ $imgUrl = get_template_directory_uri().'/images/img_404.png'; } $postoutput .= '<div class="news-box '.$nomgn.'"> <div class="news-thumb"> <a href="'.get_the_permalink().'"><img src="'.$imgUrl.'" alt="" /></a> </div> <div class="news"> <a href="'.get_permalink().'"><h6>'.get_the_title().'</h6></a> <div class="date-news"> <span><i class="fa fa-calendar"></i> Posted On <a href="'.get_day_link().'">'.get_the_time('d-M-Y').'</a></span> </div> '.content(50).' <a href="'.get_permalink().'" class="linkreadmore">Read More</a> </div> </div>'; $postoutput .= ''.(($n%3==0) ? '<div class="clear"></div>' : ''); endwhile; endif; wp_reset_query(); return $postoutput; } add_shortcode( 'latestposts', 'latestpostsoutput_func' );
同じようにincフォルダを子テーマ内に作り
custom-functions.phpをコピペして複製して
変更してみましたが変わりません。プラグインShow Current Templateで見てみても、
子テーマ内のcustom-functions.phpは読み込んでないようです。
親テーマのcustom-functions.phpは読み込まれてました。同じファイル名だと子テーマの方が優先されるかと思ったのですが
やり方が違うのでしょうか?どうぞよろしくお願いします。
フォーラム: 使い方全般
返信が含まれるトピック: 静的ページにWPの更新情報を導入後、真っ白い画面静的ページHTMLの一行目の
<?php require('./blog/wp-blog-header.php'); ?>
を
<?php require_once('blog/wp-load.php'); ?>
に変えて再度アップしたら表示されました。でも気になってもう一度
<?php require('./blog/wp-blog-header.php'); ?>
に戻してアップして見た所
以前のコードでもちゃんと表示されました。ということは、
一行目ではなく何が原因だったのか。。?ちょっとわかりませんが
とりあえず解決しました!お騒がせいたしました。
フォーラム: 使い方全般
返信が含まれるトピック: シングルページだと表示されないお世話になります。
>mypacecreatorさんのブログをよく見直し
‘category_name’を’cat’に変更したらうまくいきました!
アーカイブは
‘cat’ => $cat_idシングルは
‘cat’ => $cat_s_idとしたところ正常にそのカテゴリだけ表示されました。
大変勉強になりました。
ありがとうございました。フォーラム: 使い方全般
返信が含まれるトピック: シングルページだと表示されない>mypacecreatorさん
お世話になります。
ありがとうございます。頂いたコードを参考に再構築してみました。
<?php $cat_id = get_query_var('cat'); $cat = get_category($cat_id); $cat_parent_id = $cat->category_parent; $cat_parent = get_category($cat_parent_id); ?> <?php if(is_category('xxx')||$cat_parent_id == 1): if( $cat_parent_id == 0 ): //親カテゴリの場合 ?> <h2>最新記事一覧</h2> <?php else: //子カテゴリの場合 ?> <h2>最新記事一覧</h2> <p>カテゴリー:<a href="<?php echo get_category_link($cat_id); ?>"><?php single_cat_title(); ?></a></p> <?php endif; ?> <ul> <?php $newslist = get_posts( array( 'category_name' => $cat_ID )); foreach( $newslist as $post ): setup_postdata( $post ); ?> <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> <li class="sMore"><a href="<?php echo get_category_link($cat_id); ?>">><?php single_cat_title(); ?>一覧へ</a></li> </ul> <?php endif; ?> <?php if(is_single()): $cat_s = get_the_category(); $cat_s = $cat_s[0]; $cat_s_id = $cat_s->cat_ID; if( $cat_s_id == 0 ): //親カテゴリの場合 ?> <h2>最新記事一覧</h2> <?php else: //子カテゴリの場合 ?> <h2>最新記事一覧</h2> <p>カテゴリー:<a href="<?php echo get_category_link($cat_s); ?>"><?php echo get_cat_name($cat_s_id); ?></a></p> <?php endif; ?> <ul> <?php $newslist = get_posts( array( 'category_name' => $cat_ID )); foreach( $newslist as $post ): setup_postdata( $post ); ?> <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> <li class="sMore"><a href="<?php echo get_category_link($cat_s_id); ?>">><?php echo get_cat_name($cat_s_id); ?>一覧へ</a></li> </ul> <?php endif; ?>
get_postsを使った記述に変更してみました。
表示が出来ましたがアーカイブ、シングルともに全カテゴリで表示されてしまいます。‘category_name’ => $cat_ID
↑この部分を変更するのかなと思い
アーカイブは
‘category_name’ => $cat_idシングルは
‘category_name’ => $cat_sにしてみましたが、
そうすると表示されなくなってしまいます。。。
他$cat、$cat_s_id等も試してみましたが出来ませんでした。。あと少しかと思いますが、、
アドバイス頂けると幸いです。どうぞよろしくお願いいたします。
フォーラム: 使い方全般
返信が含まれるトピック: シングルページだと表示されないご回答頂きありがとうございます。
説明不足で申し訳ございませんでした。
テーマは自作のものになります。またコードの記述もれがあり
先ほどのコードの前に以下のコードがありました。<?php $cat_id = get_query_var('cat'); $cat = get_category($cat_id); $cat_parent_id = $cat->category_parent; $cat_parent = get_category($cat_parent_id); ?>
また今回このコードが入っているファイルが
サイドバー(sideber.php)になります。
single.php、archive.php ともにこのsideber.phpを読み込んでおります。ただシングルとアーカイブを変えたらいいと思い込んでおりました。
先ほどのif(is_single())以下に
下のコードを差し替えたらなんとかうまくいきそうです。<?php $cat = get_the_category(); $cat = $cat[0]; $cat_ID = $cat->cat_ID; ?> <?php if( $cat_ID == 0 ): //親カテゴリの場合 $cat_parent = get_category($cat_ID); ?>
これからすぐに検証が難しくまだちゃんと確認はできていないのですが、
できましたらまた後ほどご報告させていただきます。もし他にも何かアドバイスがあればご指摘頂けると幸いです。
どうぞよろしくお願いします。