について、お知恵をお貸しください。
-
この4グループをhtml上で別々に表示
完成系がこのご説明だとイメージできないのでちょっと回答できかねます。
もう少し具体的に、どういう結果になればいいのかお書きいただけないでしょうか?mypacecreator様
ありがとうございます、すみませんでした。
content.phpに下記を書いて(貼り付けて)いまして、どうしても?????マークのImgBgroupの出し方がわかりません。<?php if (is_single()): ?>
<?php //記事と画像の分割
$img = ‘/\<img ([^\>]+)\>/i’;
$text = get_the_content();
preg_match_all($img,$text,$matches);
$image = $matches[0][0];
$people_img = $matches[0][1];
$text = preg_replace($img,””,$text);
?><div class=”left-content”>
<h1 class=”page-title”><?php the_title(); ?></h1>
<time pubdate=”pubdate” datetime=”<?php the_time(‘Y-m-d’); ?>” class=”entry_date”><?php the_time(get_option(‘date_format’)); ?></time><?php if(is_user_logged_in()):
if (!is_search()):
echo the_author_posts_link(). ‘
‘;
endif;
echo get_comments_number() . ‘件のコメント
‘;
else:
echo the_author(). ‘
‘;
endif; ?></div><!–/left-content –>
<div class=”right-content”>
<?php if(is_user_logged_in()):
// TextAgroup
$content = get_the_content();
$content = preg_replace(“|(<img[^>]+>)|si”,””,$content);
echo $content;
else:
// TextBgroup
global $more;
$more = 0;
$content = get_the_content(” , FALSE, ”);
$content = preg_replace(“|(<img[^>]+>)|si”,””,$content);
echo $content;
if ($pos=strpos($post->post_content, ‘<!–more–>’)):
echo ‘ログイン‘;
endif;
endif; ?>
<!–複数画像–>
<?php if(is_user_logged_in()):
// ImgAgroupおよびImgBgroup????????
else:
// ImgAgroupのみ
post_linkingthumbs();
endif; ?>
</div><?php else: ?>
<h1 class=”page-title”><?php the_title(); ?></h1>
<?php the_content(); ?>
<?php endif; ?>//——- funtions.php
function post_linkingthumbs($maxcnt=’-1′, $imgsize=array()){
global $post;
$args = array(
‘post_type’ => ‘attachment’,
‘numberposts’ => $maxcnt, //取得する画像数(-1の場合は全て)
‘post_status’ => inherit,
‘post_parent’ => $post->ID,
‘post_mime_type’ => ‘image’,
‘orderby’ => ‘menu_order ID’,
);
$attachments = get_posts($args);
if (is_array($attachments)) {
//取得したサムネイル数分出力
foreach ($attachments as $attachment) {
echo ‘<div class=”col-md-4 col-sm-6″>guid.'” title=”‘.$attachment->post_title.'”><span class=”overlay-zoom margin-bottom-10″>’.wp_get_attachment_image($attachment->ID,’attachment-thumbnail’, true, array(‘class’=>’img-responsive’)). ‘<div class=”zoom-icon”></div></span></div>’;
}
}
}
どうぞ、よろしくご教示お願いします。すみません、長いコードは読みづらく、しかも一部消えてしまっているので、
http://ja.forums.wordpress.org/topic/11?replies=3
このルールに沿って貼ってもらえますでしょうか。また、若干複雑な処理が入ったテーマのようですが、テーマはなんですか?
どこかのサイトを参考にされてカスタマイズを加えているようならその情報もお願いします。※ImgAgroupとかがなにを指しているのかがいまいちわかっていません…カスタムフィールドですか???
どういう表示にしたいのかが文面から分からず…使い方知らずにすみません。
今、Bootstrapレシポンシブのテンプレートを購入しサイトを構築中です。
無謀にも書籍やネットの情報を下に、自分でカスタマイズしています。
短くして、下記に貼り付けました。
http://pastebin.com/cy06TJcd
#4行目は投稿記事<!–more–>全ての投稿された記事テキスト
#9行目は投稿記事<!–more–>以後の投稿された記事テキスト
#23行目は投稿記事<!–more–>の前に投稿された画像(複数)
#25行目は投稿記事<!–more–>の後に投稿された画像(複数)
登録会員だけは、ログイン後に全ての記事と画像を閲覧できるように
見やすくし、制限をかけたいと思います。すみません、functions.phpのソース入れるの忘れました。
下記に入っています。
http://pastebin.com/YaMAcXeF結果的にでれば必要ないのですが…。
よろしくお願いします。有償テーマですか、、、
(有償テーマは、回答者が同じものを用意できないので、このフォーラムでは回答が付きづらい傾向があります。)通常のWordPressには書いていただいたような機能は標準では備わっていないので、
独自の関数を作ってあるのだと思います。一部のコードを貼っていただきましたが、
テーマ全体を見てみないとわかりません。ごめんなさいm(_ _)m
有償テーマということなので、購入元のサポートとかはないですか?見たところ、
post_linkingthumbs()
という関数は、投稿に紐づけられている画像すべて取り出してきて表示するという関数になっております。
imgGroupAとimgGroupBに何か差別化する属性 ( class名とかなど ) が有れば、正規表現でまだ分割出来るかも知れませんが、
もう、advanced custom fields とかのプラグインでカスタムフィールドを作成し、
ログイン時以外は非表示する画像・テキストを別にした方がいいと思います。
その方が今後も楽です。
- トピック「について、お知恵をお貸しください。」には新たに返信することはできません。