Add post meta

Hi Guys,

We have a couple of sites running on betheme with one of them being a big blog site. Although most people want the post meta (author, date, category) to be removed, on this site we want to show it the following meta data when reading a post:
- date
- date last modified
- amount of time needed to read it (via plugin, can use a shortcode)

Now, date (created/published) is working obviously, but is it possible to add the last modified date of that post, to the post meta? Same goes for the plugin shortcode.

Many thanks in advance, best regards,
Niels

Comments

  • HI,
    sorry but all of this requires file modification and additional code which we do not support.
    Those are the default wordpress post options.
    thanks
  • Hi,

    My client keeps requesting this so I am forced to look into this again.

    It seems that wordpress does know the modified date. For Example, Jetpack adds it as an opengraph tag:
    <meta property="article:published_time" content="2016-10-02T10:30:41+00:00" />
    <meta property="article:modified_time" content="2018-01-09T14:10:16+00:00" />

    From the post source it's the following code:
    <div class="post-meta clearfix">
        <div class="author-date">
            <span class="date">
                <i class="icon-clock"></i>
                <time class="entry-date updated" datetime="2016-10-02T12:30:41+00:00" itemprop="datePublished" >2 oktober 2016</time>
                <meta itemprop="dateModified" content="2016-10-02T12:30:41+00:00"/>
            </span>
        </div>
    </div>


    This comes from the content-post.php, starting at line 156:

    if( isset( $list_meta['date'] ) ){
        $output .= '<span class="date">';    
            if( isset( $list_meta['author'] ) ) $output .= '<span class="label">'. $translate['at'] .' </span>';    
            $output .= '<i class="icon-clock"></i> ';    
            $output .= '<span class="post-date updated">'. get_the_date() .'</span>';    
        $output .= '</span>';
    }


    To me, it doesn't seem to hard to add an extra line which outputs the modified date and time. I could add this myself but ofcourse this would not survive an update from the theme (which is working perfect since this is integrated with Wordpress updates!) Combine this with a switch in the Betheme options and you've added a functionality which is used on many blogs these days.

    It would be greatly appreciated if you can look into this again, and if you agree with me on this then please add this feature in upcoming theme updates.

    Many thanks in advance, best regards,
    Niels
  • Hi,
    ofcrourse you can add it, just use a child theme and modify it in your liking. Then it will not change upon theme updates.
    thanks
  • For those who are wondering, I added the following code to content-single.php (wp-content/themes/betheme/includes/):

                                                <?php if( get_the_modified_time('U') >= get_the_time('U') + 86400 ) : ?>
                                                <span>- last modified: </span>
                                                <time class="entry-date modified" datetime="<?php echo get_the_modified_time('c'); ?>" itemprop="dateModified" ><?php echo get_the_modified_date(); ?></time>
                                                <?php endif; ?>


    underneath: <?php if( isset( $single_meta['date'] ) ): ?>
    which is the code for showing the published date.

    It probably isn't the most beautifull solution but I've hardly done any programming in php so I'm happy with it. Btw, it checks whether it has been more than 24 hours before showing the last modified date.


    To muffin support, it would be really could if you can turn this in a betheme future.
Sign In or Register to comment.
This website uses cookies

We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you’ve provided to them or that they’ve collected from your use of their services.

Cookies are small text files that can be used by websites to make a user's experience more efficient.

The law states that we can store cookies on your device if they are strictly necessary for the operation of this site. For all other types of cookies we need your permission. This means that cookies which are categorized as necessary, are processed based on GDPR Art. 6 (1) (f). All other cookies, meaning those from the categories preferences and marketing, are processed based on GDPR Art. 6 (1) (a) GDPR.

This site uses different types of cookies. Some cookies are placed by third party services that appear on our pages.

You can at any time change or withdraw your consent from the Cookie Declaration on our website.

Learn more about who we are, how you can contact us and how we process personal data in our Privacy Policy.

Please state your consent ID and date when you contact us regarding your consent.