0

I've created a custom field and selected "Filter by role" to "Subscriber" and assigned the custom field to the post type. Now when I add a new post and assigned the subscriber (ie: created a Test Post and assigned the subscriber to "grade 1") after I click on the update again I changed the subscriber "grade 1" to "grade 2", after that when I viewed the page by login as grade 1 that particular post is viewed. This Happens only if I edit the post and change the subscriber again.

$args_events = array(
    'post_type' => 'parents_login',
    'post_status' => 'publish',
    'paged' => $page_num,
    'posts_per_page' => CUSTOM_ROWS_PER_PAGE,
    'cat' => get_cat_id( single_cat_title("",false) ),
    'meta_query' => array(
        'relation' => 'OR',
        array(
            'key' => 'select_grade',
            'value' => $current_user->ID,
            'compare' => 'LIKE',
        ),
    ),
);

2 Answers 2

0

Change OR to AND

Where is your $current_user; variable?

I see it in your code, but not the value that it has.

Please update code

0
$args_events = array(
        'post_type' => 'parents_login',
        'post_status' => 'publish',
        'posts_per_page' => CUSTOM_ROWS_PER_PAGE,
        'cat' => get_cat_id( single_cat_title("",false) ),
        'meta_query' => array(
           array(
               'key' => 'select_grade',
               'value' => serialize( strval( $current_user->ID ) ),
               'compare' => 'LIKE'
            ),
         ),
);

Using this I attained result. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.