Skip to main content
edited tags
Link
RiddleMeThis
  • 3.8k
  • 8
  • 21
  • 30
added 50 characters in body
Source Link
RiddleMeThis
  • 3.8k
  • 8
  • 21
  • 30

I using the below code to get modified data for the post, but I need to get the same modified post for my other custom posts. For example, it works if i change post to test( my custom post type name)"if( 'post' === get_post_type() )", but i need for both test, post and movies etc.

function et_last_modified_date_blog( $the_date ) { if ( 'post' === get_post_type() ) { $the_time = get_post_time( 'His' ); $the_modified = get_post_modified_time( 'His' );

function et_last_modified_date_blog( $the_date ) {
    if ( 'post' === get_post_type() ) {
        $the_time = get_post_time( 'His' );
        $the_modified = get_post_modified_time( 'His' );

        $last_modified =  sprintf( __( 'Last updated %s', 'Divi' ), esc_html( get_post_modified_time( 'M j, Y' ) ) );
        $date = $the_modified !== $the_time ? $last_modified : get_post_time( 'M j, Y' );

        return $date;
    }
}
add_action( 'get_the_date', 'et_last_modified_date_blog' );
add_action( 'get_the_time', 'et_last_modified_date_blog' );

} add_action( 'get_the_date', 'et_last_modified_date_blog' ); add_action( 'get_the_time', 'et_last_modified_date_blog' );

I using the below code to get modified data for the post, but I need to get the same modified post for my other custom posts. For example, it works if i change post to test( my custom post type name)"if( 'post' === get_post_type() )", but i need for both test, post and movies etc.

function et_last_modified_date_blog( $the_date ) { if ( 'post' === get_post_type() ) { $the_time = get_post_time( 'His' ); $the_modified = get_post_modified_time( 'His' );

    $last_modified =  sprintf( __( 'Last updated %s', 'Divi' ), esc_html( get_post_modified_time( 'M j, Y' ) ) );
    $date = $the_modified !== $the_time ? $last_modified : get_post_time( 'M j, Y' );

    return $date;
}

} add_action( 'get_the_date', 'et_last_modified_date_blog' ); add_action( 'get_the_time', 'et_last_modified_date_blog' );

I using the below code to get modified data for the post, but I need to get the same modified post for my other custom posts. For example, it works if i change post to test( my custom post type name)"if( 'post' === get_post_type() )", but i need for both test, post and movies etc.

function et_last_modified_date_blog( $the_date ) {
    if ( 'post' === get_post_type() ) {
        $the_time = get_post_time( 'His' );
        $the_modified = get_post_modified_time( 'His' );

        $last_modified =  sprintf( __( 'Last updated %s', 'Divi' ), esc_html( get_post_modified_time( 'M j, Y' ) ) );
        $date = $the_modified !== $the_time ? $last_modified : get_post_time( 'M j, Y' );

        return $date;
    }
}
add_action( 'get_the_date', 'et_last_modified_date_blog' );
add_action( 'get_the_time', 'et_last_modified_date_blog' );
Source Link

How to get 2 or multiple custom post types in wordpress functions.php

I using the below code to get modified data for the post, but I need to get the same modified post for my other custom posts. For example, it works if i change post to test( my custom post type name)"if( 'post' === get_post_type() )", but i need for both test, post and movies etc.

function et_last_modified_date_blog( $the_date ) { if ( 'post' === get_post_type() ) { $the_time = get_post_time( 'His' ); $the_modified = get_post_modified_time( 'His' );

    $last_modified =  sprintf( __( 'Last updated %s', 'Divi' ), esc_html( get_post_modified_time( 'M j, Y' ) ) );
    $date = $the_modified !== $the_time ? $last_modified : get_post_time( 'M j, Y' );

    return $date;
}

} add_action( 'get_the_date', 'et_last_modified_date_blog' ); add_action( 'get_the_time', 'et_last_modified_date_blog' );