Skip to:

Show a link only if it exists?

  • corporatefin


    On the profile page of each author on my blog, I want to show a link to all posts by a user.

    Okey, that part is easy. But I want to show something else, if the author has not yet made any posts, such as “This author has not made any posts yet”.

    At the moment, the link looks like this:

    “>Show all posts by <?php bp_user_fullname() ?>

    But if the user has not made any posts, they end up at the 404 page, which is a bit unprofessional.

    Is it possible to fix this with some nice coding?

    Any help highly appreciated.

    I am using WordPress MU and Buddypress (latest versions)

Viewing 3 replies - 1 through 3 (of 3 total)

  • corporatefin


    oops. I now realise the code was cut in pieces.

    This is the link I want to add an if statement to:

    <a href="/overlatelser/<?php echo bp_core_get_username(bp_displayed_user_id()); ?>">Show all posts by <?php bp_user_fullname() ?> </a>



    Use to get the blogs of the user, then count the posts on every blog, add them all together and you’ll see wether a user has any posts or not.



    Thanks for your reply, since I am not very good at php, this sound like a foreign language to me. hmm.

    Also, all the users are on the same blog, which probably means that I have to count posts by the author instead?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show a link only if it exists?’ is closed to new replies.
Skip to toolbar