• Hi,

    I am using the SilverOrchid theme by Gazpo and it has five “featuring categories” in the Index page showing pics and excerpts. I was wondering if it was possible to justify the text of those excerpts.

    My website is https://www.putrumputrum.com/en

    The code for each of the feat_cat.php for showing the excerpts is:

    <div class="post-meta">
    <span class="date"><?php the_time('F j'); ?></span>
    <span class="comments"><?php comments_popup_link( __('no comments', 'silverorchid'), __( '1 comment', 'silverorchid'), __('% comments', 'silverorchid')); ?></span>
    </div>
    <p>
    <?php
    $content = get_the_excerpt();
    $content = strip_tags($content);
    $content = strip_shortcodes( $content );
    echo mb_substr($content, 0, 200). ''
    ?>
    </p>
    </div>
    </li>
    <?php

    Can somebody help me out with this? I know nothing about php.

    Thanks in advance.

Viewing 7 replies - 1 through 7 (of 7 total)
  • I can’t find a copy of the theme to take a look at it, so this is just a wild guess. Try this in the style sheet – or css options page, if the theme has it.

    #content .feat-cat .left p {
    text-align: justify;
    }

    Thread Starter Goodvalley

    (@goodvalley)

    No, it doesn’t work.

    The code I just put belongs to each of the 5 feat_cat.php files. So there’s feat_cat1.php, feat_cat2.php, etc.

    I think there must be a piece of php code to add to the code above.

    What if you left out the .left and just put:

    .feat-cat p {
        text-align: justify;
    }
    Thread Starter Goodvalley

    (@goodvalley)

    No, it’s not working.

    I’ve put

    .feat_cat1 p {
        text-align: justify;
    }

    and

    .feat_cat1.php p {
        text-align: justify;
    }

    in the styles.css, but nothing.

    So there’s feat_cat1.php, feat_cat2.php, etc.

    I’m not positive, but I think you might want to work with the css, not the code in your php files. When I use firebug on your site and add this to the bottom of style.css;

    #content .feat-cat .left p {
    text-align: justify;
    }

    ..it justifies only the text inside the p tags of the excerpts on the featured posts.. all 5 of them.

    It looks like those p tags around the excerpt are located in this order: (div id) #content > (div class).feat-cat > (div class).left > p tags.

    I’m not very good with CSS, but it seems to work for me on the live edit using Firebug.

    Thread Starter Goodvalley

    (@goodvalley)

    You are absolutely right, Clayton.

    The text in the main featured post (big pic on the left in every featured category) is justified as you said. But I was looking also at the three other excerpts (little ones) on the right, which didn’t change, so I thought it didn’r work.

    Obviously, I wrote

    #content .feat-cat .left p,
    #content .feat-cat .right p {
    text-align: justify;
    }

    adding the “right” piece of code and now everything is perfect.

    Thanks very much, you were spot on!

    You’re welcome! Glad that worked. Keep an eye out for anything else that might have been affected, but I don’t think there should be any side effects.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Justifying text in an excerpt?’ is closed to new replies.