• Resolved bigvibes

    (@bigvibes)


    I have this snippet below and it appears at the beginning of the content (it shows the last updated date of the article), but I want it to appear at the end. How do I do that?

    function wpb_last_updated_date( $content ) {
    $u_time = get_the_time(‘U’);
    $u_modified_time = get_the_modified_time(‘U’);
    if ($u_modified_time >= $u_time + 86400) {
    $updated_date = get_the_modified_time(‘F jS, Y’);
    $updated_time = get_the_modified_time(‘h:i a’);
    $custom_content .= ‘<p class=”last-updated”>Last updated on ‘. $updated_date . ‘</p>’;
    }

    $custom_content .= $content;
    return $custom_content;
    }
    add_filter( ‘the_content’, ‘wpb_last_updated_date’ );

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    Simple: change this line:

    $custom_content .= $content;

    to this:

    $custom_content = $content . custom_content;

    Thread Starter bigvibes

    (@bigvibes)

    Thanks, but I tried doing that and now the post just displays the text custom_content at the end of the post, the function doesn’t work anymore

    Plugin Author Shea Bunge

    (@bungeshea)

    My apologies, I left a character out of my post.

    Instead, change the line to this:

    $custom_content = $content . $custom_content;

    Thread Starter bigvibes

    (@bigvibes)

    Works great now, thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to change location of snippet?’ is closed to new replies.