<select name="select-city" onchange="location = this.value;"> <option value="">Select a post to read</option> <?php if ( is_user_logged_in() ): global $current_user; wp_get_current_user(); $author_query = array('posts_per_page' => '-1','author' => $current_user->ID); $author_posts = new WP_Query($author_query); $numposts = $count_user_posts( $user_id ); while($author_posts->have_posts()) : $author_posts->the_post(); ?> <option value="<?php the_permalink(); ?>"><?php the_title(); ?></option> <?php elseif ($numposts == 0): echo 'You have no posts'; ?> <?php endwhile; else : echo '<a href="https://www.mysiteeeee.com/wp-login.php" >Log in</a>'; endif; ?>
Hello there, I'm trying to make this work but I don't get it.
If user is logged in I get a form dropdown of the posts the user has published. If it has no posts I get the message "You have no posts". And if user is not logged in a link to log in prints.
I don't get it to work with the second part "You have no posts"
What am I doing wrong? Thanks.