【问题标题】:styling A word press content manually with code使用代码手动设置 wordpress 内容样式
【发布时间】:2021-10-04 04:01:06
【问题描述】:

我正在尝试设置位于 Single.php 文件中的我的 WP 帖子的样式, 作为记录,此文件包含

">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div  <?php post_class() ?> id="post-<?php the_ID(); ?>">
     <div class="card-header">
            <h2><a title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
     </div>
     <div class="card-body">
           <div class="entry">
                  <?php the_content(); ?>
            </div>
     </div>
</div>
<?php endwhile; endif; ?>

而且我不知道如何设置它的样式,因为上述帖子中没有任何类。 任何想法如何使用代码和手动设置我的内容样式???

【问题讨论】:

    标签: php html css wordpress styles


    【解决方案1】:
    You can do it with following code.
    
    first you will have to declare a class 
    
    <div  <?php post_class() ?> id="post-<?php the_ID(); ?>" <?php post_class("my-custom-css"); ?>>
    
    now you define css in your theme css file
    
    .my-custom-css{
    //do css stuff here
    }
    

    【讨论】:

    • 所以这里可以说我有一个帖子,我想更改上面的 col
    猜你喜欢
    • 2022-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-03
    相关资源
    最近更新 更多