Black Friday sale! Get 25% off WPSP Pro! Discount automatically applied at checkout.

[Resolved] Add image with month and day left of post title

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Add image with month and day left of post title

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #15915
    Mike
    Participant

    I’m prototyping a new client website and have run into an issue with incorporating WP ShowPosts into the website while meeting one of the client’s requirements.

    The existing website is built with DNN (yes, there are still some DotNetNuke websites around) and has an image incorporating the client’s logo along with the month and date left of the title for each post. I have replicated this with the code below. Actually, I improved on it.

    This formatting is shown in NEWS/RESOURCES > NEWS & EVENTS, which is set as the “Posts” page.

    The page, NEWS/RESOURCES > ARTICLES is a WP ShowPosts feed. It loses the formatting adding the image (along with month and day) left of the post title. I welcome suggestions on how to do this with WP ShowPosts. Rather than spending many hours trying to figure out what to target in WP ShowPosts I came to the source.

    THANKS!

    The CSS added to style.css of the GeneratePress child theme:
    
    /* Calendar icon for posts     */
    
    .calendaricon {
        float: left;
        background: #fff;
        margin-right: .75em;
        margin-left: -1em;
        height: 90px;
        width: 143px;
    }
    
    .month {
        color: #b44401;
        font-family: Georgia,serif;
        font-size: 26px;
        font-weight: bold;
        text-shadow: 1px 1px #000;
        text-align: center;
        margin-top: -3.9em;
        text-transform: uppercase;
    }
    
    .day {
        padding-top: 14px;
        width: 35px;
        color: #fff !important;
        font-family: Arial, sans-serif;
        font-weight: 500;
        text-shadow: 1px 2px #000065;
        font-size: 24px;
        text-align: center;
        padding-left:17px;
    }
    
    .inside-article .entry-header .entry-title  {
        font-size: 26px !important;
        line-height: 1;
        color: #b44401;
        font-weight: 500;
        text-shadow: 1px 1px #000065;
    }

    Added to functions.php:

    /* CALENDAR DATE ICON */
    function calendar (){ ?>
    <div class="calendaricon">
    <? echo '<img src="https://myimage_url.com/wp-content/uploads/2020/05/cal_w_logo_starfleet.png" />'; ?>
    <div class="month"><? the_time('M') ?></div>
    <div class="day"><? the_time('j') ?></div>
    </div>
    <?
    }
    add_action('generate_before_entry_title', 'calendar');
    #15919
    Mike
    Participant

    Resolved by adding wpsp_before_title hook to functions.php.

    /* CALENDAR DATE ICON */
    function calendar (){ ?>
    <div class="calendaricon">
    <? echo '<img src="https://myimage_url/wp-content/uploads/2020/05/cal_w_logo_starfleet.png" />'; ?>
    <div class="month"><? the_time('M') ?></div>
    <div class="day"><? the_time('j') ?></div>
    </div>
    <?
    }
    add_action('generate_before_entry_title', 'calendar');
    
    add_action('wpsp_before_title', 'calendar');

    Thanks Tom!

    • This reply was modified 6 months, 1 week ago by Mike.
    • This reply was modified 6 months, 1 week ago by Mike.
    #15933
    Tom
    Keymaster

    No problem! Thanks for posting the solution 🙂

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.