1

構築中のサイトの CMS として Wordpress を使用しています。

ページ テンプレート:

    <?php get_header(); ?>

    <!-- Class here -->

    <div id="wrap">
        <div id="content" class="column">
            <?php if( have_posts() ): while( have_posts() ): the_post(); ?>

            <div class="post">

            <?php the_content(); ?>

            </div>

            <?php endwhile; endif; ?>
        </div>

        <div id="sidebar" class="column">
            <?php get_sidebar(); ?>
        </div>
    </div>

</div>

</div>
&nbsp;
<div>

<?php get_footer(); ?>

" " のクラスの div が必要です。theslide前に#wrap (Class here)呼び出され、その後の php によって再度呼び出されないようにします。

「 」の線に沿って何かできるget_post if class=theslideでしょうか?

ありがとうございました。

4

2 に答える 2

0

すべての情報をありがとう、私の友人が私を助けてくれました。

他の誰かが同じ問題を抱えている場合:

<?php if( have_posts() ): while( have_posts() ): the_post();

$post_content = get_the_content();
preg_match('/(<div.*?class="theslide".*?<\/div>)(.*)/ism', $post_content, $content);

if( isset($content[1]) )
{
    echo $content[1];            //print the "theslide" div
    $page_content = $content[2];
}
else
{
    $page_content = $post_content;

}
?>

<div id="wrap">
    <div id="content" class="column">

        <div class="post">
            <?php echo $page_content; ?>
        </div>

    </div>
    <div id="sidebar" class="column">
        <?php get_sidebar(); ?>
    </div>
</div>
<?php endwhile; endif; ?>
于 2013-04-30T12:50:50.040 に答える
0

このプラグインを使用して、投稿にカスタム フィールドを追加できます http://wordpress.org/extend/plugins/advanced-custom-fields/

そして、ループで、次のような条件を追加できます

<?php 
     if(get_field('your_field_name' )){
        //add class 
     }
 ?>
于 2013-04-25T13:11:46.597 に答える