Skip to main content
deleted 13 characters in body
Source Link
rudtek
  • 6.3k
  • 5
  • 30
  • 52

Hello guys i'mI'm trying to get logged in users most recently read 10 posts to show on their profile.

For example,: user A's most recently read 10 posts user B's most recently read 10 posts...

iI tried creating this short codeshortcode to do it, but it doesn't show me any result either error. howHow can iI fix this  ?

function shortcode_recent (){
if( is_user_logged_in() ) {
 $post_id= get_the_ID();
    update_post_meta( $post_id, 'post_readed_by', get_current_user_id() );
    $args = array(
    'posts_per_page'   => 10,
    'meta_key'         => 'post_readed_by',
    'meta_value'       => get_current_user_id(),
    'post_type'        => 'post',
    'post_status'      => 'publish',
);
$posts_array = get_posts( $args );
foreach ( $posts_array as $post ) : setup_postdata( $post );

    the_title();
    if ( has_post_thumbnail() ) {
        the_post_thumbnail();
    } 
    the_content();

endforeach; 
wp_reset_postdata();
}

}
add_shortcode('post_recent',shortcode_recent );

Hello guys i'm trying to get logged in users most recently read 10 posts to show on their profile.

For example, user A's most recently read 10 posts user B's most recently read 10 posts...

i tried creating this short code to do it, but it doesn't show me any result either error. how can i fix this  ?

function shortcode_recent (){
if( is_user_logged_in() ) {
 $post_id= get_the_ID();
    update_post_meta( $post_id, 'post_readed_by', get_current_user_id() );
    $args = array(
    'posts_per_page'   => 10,
    'meta_key'         => 'post_readed_by',
    'meta_value'       => get_current_user_id(),
    'post_type'        => 'post',
    'post_status'      => 'publish',
);
$posts_array = get_posts( $args );
foreach ( $posts_array as $post ) : setup_postdata( $post );

    the_title();
    if ( has_post_thumbnail() ) {
        the_post_thumbnail();
    } 
    the_content();

endforeach; 
wp_reset_postdata();
}

}
add_shortcode('post_recent',shortcode_recent );

I'm trying to get logged in users most recently read 10 posts to show on their profile.

For example: user A's most recently read 10 posts user B's most recently read 10 posts...

I tried creating this shortcode to do it, but it doesn't show me any result either error. How can I fix this?

function shortcode_recent (){
if( is_user_logged_in() ) {
 $post_id= get_the_ID();
    update_post_meta( $post_id, 'post_readed_by', get_current_user_id() );
    $args = array(
    'posts_per_page'   => 10,
    'meta_key'         => 'post_readed_by',
    'meta_value'       => get_current_user_id(),
    'post_type'        => 'post',
    'post_status'      => 'publish',
);
$posts_array = get_posts( $args );
foreach ( $posts_array as $post ) : setup_postdata( $post );

    the_title();
    if ( has_post_thumbnail() ) {
        the_post_thumbnail();
    } 
    the_content();

endforeach; 
wp_reset_postdata();
}

}
add_shortcode('post_recent',shortcode_recent );
Source Link

Show users last read posts for each user?

Hello guys i'm trying to get logged in users most recently read 10 posts to show on their profile.

For example, user A's most recently read 10 posts user B's most recently read 10 posts...

i tried creating this short code to do it, but it doesn't show me any result either error. how can i fix this ?

function shortcode_recent (){
if( is_user_logged_in() ) {
 $post_id= get_the_ID();
    update_post_meta( $post_id, 'post_readed_by', get_current_user_id() );
    $args = array(
    'posts_per_page'   => 10,
    'meta_key'         => 'post_readed_by',
    'meta_value'       => get_current_user_id(),
    'post_type'        => 'post',
    'post_status'      => 'publish',
);
$posts_array = get_posts( $args );
foreach ( $posts_array as $post ) : setup_postdata( $post );

    the_title();
    if ( has_post_thumbnail() ) {
        the_post_thumbnail();
    } 
    the_content();

endforeach; 
wp_reset_postdata();
}

}
add_shortcode('post_recent',shortcode_recent );