Support » Themes and Templates » If post belong to author and if post in category x then show edit/delete

  • Hi everyone I am trying to show an edit and delete button (frontend)in the single post based on 2 conditions.
    1.) is the current logged in user the author of the post AND
    2.) is the Post in the category ‘X’

    if both conditions is met then display an edit and delete ink, if not then don’t give the edit and delete link.

    <?php edit_post_link( __( 'edit',
     'twentyten' ), '<span class="edit-link">', '</span>' ); ?>

    the above snippet already checks for author of post (by theme default) so how do I add the category condition in it?

    is this conditional tag to use?
    <?php is_category( $category ); ?>

    I have tried it didn’t work maybe I have done it wrong.

    Thanks everyone

Viewing 1 replies (of 1 total)
  • let me update my question and make it more clearer
    the following is in my loop-single.php

    <?php	global $current_user;
     if ($post->post_author == $current_user->ID) { ?>
      <a onclick="return confirm('you sure you want to delete?')" href="<?php echo get_delete_post_link( $post->ID ) ?>">delete post</a>
    <?php } ?>

    I want to add the condition is this post in the category 7?
    I assume I use the <?php in_category( $category, $_post ) ?>
    But where and how do I add it?

    can anyone please help me out here

Viewing 1 replies (of 1 total)
  • The topic ‘If post belong to author and if post in category x then show edit/delete’ is closed to new replies.