0

My theme developer won't help give me an answer on how to add this feature to the current theme. I looked into the Wordpress documentation and tried to add code to function.php file but it placed the code on the top of the page. I tried to add the PHP code Wordpress suggests but it broke the theme.

Looks like this is a custom code seeing as it is a custom theme. The theme author said to place in the article.php.

Any help would be most welcome.

Currently:
July 11, 2017 in CATEGORY 0 comments

Looking to have:
July 11, 2017 in CATEGORY 0 comments
Updated: July 23, 2017 at 7:00am

            <!-- ARTICLE DATE : begin -->
                `<div class="article-date">
                    <i class="ico tp tp-clock2"></i>
                    <span class="article-date-holder">
                    <?php if ( lsvr_get_field( 'article_detail_categories_enable', true, true ) ) : ?>
                        <?php $categories_html = ''; ?>
                        <?php $terms = wp_get_post_terms( get_the_id(), 'category' ); ?>
                        <?php foreach ( $terms as $term ) : ?>
                            <?php $categories_html .= '<a href="' . get_term_link( $term ) . '">' . $term->name . '</a>, '; ?>
                        <?php endforeach; ?>
                        <?php if ( $categories_html !== '' ) : ?>
                            <?php $categories_html = rtrim( $categories_html, ', ' ); ?>
                            <?php echo sprintf( '%s in %s', get_the_date(), $categories_html ); ?>
                        <?php else: ?>
                            <?php echo get_the_date(); ?>
                        <?php endif; ?>
                    <?php else: ?>
                        <?php echo get_the_date(); ?>
                    <?php endif; ?>
                    </span>
                    <?php if ( lsvr_get_field( 'article_detail_author_enable', false, true ) ) : ?>
                    <span class="article-author">
                        <?php echo sprintf( 'by %s', get_the_author_posts_link() ); ?>
                    </span>
                    <?php endif; ?>
                    <?php if( comments_open() ) : ?>
                    <span class="article-comments">
                        <?php $comment_count = get_comment_count( get_the_ID() ); ?>
                        <a href="<?php the_permalink(); ?>#comments"><?php echo @sprintf( __( '%d comments', 'lsvrtheme' ), $comment_count['approved'] ); ?></a>
                    </span>
                    <?php endif; ?>
                </div>`
                <!-- ARTICLE DATE : end -->
1

In the template, right after the echo get_the_date(), add

$before = " Modified: " ; // note spaces before and after string
$after = " "; 
the_modified_date( $d, $before, $after, $echo );

See https://codex.wordpress.org/Function_Reference/the_modified_date for date formatting options. One of those examples might be what you want to see.

Of course, you'll want to use a Child Theme, so that theme updates don't overwrite your changes. Once you create the Child Theme structure, copy your template into the Child Theme folder, then make the changes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.