Liked posts by user in one page
-
I have a category page called “likes”. I want to show liked posts by the current logged in user only, on the page. How can I achieve this?
Here is the function I use now, but this shows liked posts by all users.
function exclude_other_posts( $query ) { if( is_category( 'likes')) { $query->set( 'post_status', 'published' ); $query->set( 'post_type', 'post' ); $query->set( 'orderby', 'meta_value_num' ); $query->set( 'meta_key', '_liked' ); } } add_action( 'pre_get_posts', 'exclude_other_posts' );
- The topic ‘Liked posts by user in one page’ is closed to new replies.