• Any way to add published and updated dates to the Meta. I’m using Astra and there’s an option to replace the published date. Wondering if there’s a way to have both?

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Yep! I have this same question…
    Any updates?

    Hey Keith, I have the ready-made code for Astra users. I would love to present it here.

    //Example//

    Before- “September 13, 2020 / By OrbitGadget”
    After- “Last Updated on September 13, 2020, By OrbitGadget”

    The code is :

    function your_prefix_post_date( $output ) {
    $output = ”;
    $format = apply_filters( ‘astra_post_date_format’, ” );
    $modified_date = esc_html( get_the_modified_date( $format ) );
    $updatetxt = “Last Updated on”;
    $postedtxt = “Posted on”;
    $u_time = get_the_time(‘U’);
    $u_modified_time = get_the_modified_time(‘U’);
    $modified_on = sprintf(
    esc_html( ‘%s’, ‘%s’),
    $modified_date
    );

    if ($u_modified_time >= $u_time + 86400) {
    $output .= ”;
    $output .= ‘ ‘ . $updatetxt . ”;
    $output .= ‘ ‘ . $modified_on . ”;
    $output .= ”;
    return $output;
    }

    else {

    $output .= ”;
    $output .= ‘ ‘ . $postedtxt . ”;
    $output .= ‘ ‘ . $modified_on . ”;
    $output .= ”;
    return $output;
    }
    }
    add_filter( ‘astra_post_date’, ‘your_prefix_post_date’ );
    add_filter( ‘astra_post_meta_separator’, ‘__return_false’ );

    Now for the implementation of the above code just paste it in the functions.php if you are using a child theme. If you are not using a child theme you can use the code snippet plugin and add the above snippet.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Add Published date AND Updated date?’ is closed to new replies.