posts - How add class the_content();?

admin2025-01-07  5

How do I add a class the_content();?

<div class="csoporszoveg">
    <h3 class="csoporcim"><?php
        if ($settings['enable_link']) {
            echo '<a href="' . get_permalink($post) . '">';
        }

        the_title();

        if ($settings['enable_link']) {
            echo '</a>';
        }
        ?>
    </h3>
    <?php } ?>  
      <?php
        if ( $content_source == 'excerpt' ) {
            the_excerpt();
        } else {
            the_content();
        }
      ?> 
</div>

How do I add a class the_content();?

<div class="csoporszoveg">
    <h3 class="csoporcim"><?php
        if ($settings['enable_link']) {
            echo '<a href="' . get_permalink($post) . '">';
        }

        the_title();

        if ($settings['enable_link']) {
            echo '</a>';
        }
        ?>
    </h3>
    <?php } ?>  
      <?php
        if ( $content_source == 'excerpt' ) {
            the_excerpt();
        } else {
            the_content();
        }
      ?> 
</div>
Share Improve this question edited Feb 16, 2018 at 16:15 Howdy_McGee 20.8k24 gold badges91 silver badges175 bronze badges asked Aug 29, 2017 at 2:41 Sebestyén NagySebestyén Nagy 11 gold badge1 silver badge1 bronze badge
Add a comment  | 

3 Answers 3

Reset to default 1

You don't. You'll need to put an element around it:

<?php if ( $content_source == 'excerpt' ) { ?>
    <div class="excerpt">
        <?php the_excerpt(); ?>
    </div>
<?php } else { ?>
    <div class="content">
        <?php the_content(); ?>
    </div>
<?php } ?> 
<?php
        if ( $content_source == 'excerpt' ) {
            the_excerpt();
        } else {
        ?>
            <div class="post_content"><?php the_content(); ?><div>
        <?php
        }
?> 

Target p inside div.post_content

Like this:

<p class="description"><?php echo  get_the_content();?></p>
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736255372a276.html

最新回复(0)