Skip to:
Content
Pages
Categories
Search
Top
Bottom

Show nav items for profile users conditionally


  • enderpal444
    Participant

    @enderpal444

    I’ve set up an extra nav item we’ll call “articles” using bp_core_new_nav_item() adding a screen to the profile that shows a loop of the articles. Now I’v done this for a few extra nav items aswell all which show a loop. My issue is that I only want to display the “articles” nav item to a user if they have actually posted one. I’d of course run a check on the count of that loop like so…

    
    $profile_user = get_current_user_id( );
    $args = array(
    'post_type' => 'articles',
    'author' => $profile_user,
    'posts_per_page' => -1
    );
    $articles_query = new WP_Query($args);
    $articles_count = $articles_query->post_count;
    if ($articles_count > 0) {
    

    But then how do I use this to display the nav item conditionally?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Show nav items for profile users conditionally’ is closed to new replies.
Skip to toolbar