• Resolved eVersatile

    (@eversatile)


    I am having a problem with multiple if statements. I am using && but it seems to only work for the first statement. The code is like such:

    global $post;
    $args = array( 'post_id' => $post->ID );
    $comment = get_comments( $args );
    $user = wp_get_current_user();
    if ( 3 <= count( $comment ) && $post->post_author == $user->ID) {
        echo do_shortcode( '[button]' );
    } else {
        comment_form();
    }

    It basically stats that if there is less than 3 comments then show the comment form but if there is more than 3 and is the post author then show a button. The button shows but only if there are more than 3 comments. It doesn’t check if it is only the post author or not, like i want it to.

Viewing 1 replies (of 1 total)
  • Thread Starter eVersatile

    (@eversatile)

    After a ton of playing around with the code, I have found the solution.

    global $post,$current_user;
    $args = array( 'post_id' => $post->ID );
    $comment = get_comments( $args );
      get_currentuserinfo();
      if ($post->post_author == $current_user->ID ) {
        echo do_shortcode( '[button]' );
    } elseif ( 3 <= count( $comment ) ) {
    // blank
    } else {
        comment_form();
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Multiple if statements issue’ is closed to new replies.