php - WordPress look - Can't get else to work -



have been trying time solve don't see problem is.


this code

<?php //get post ids posts start letter a, in title order, //display posts global $wpdb; $char_k = 'a';   $postids = $wpdb->get_col($wpdb->prepare(" select      id        $wpdb->posts       substr($wpdb->posts.post_title,1,1) = %s order    $wpdb->posts.post_title",$char_a));   if ($postids) { $args=array( 'post__in' => $postids, 'post_type' => 'encyklopedi', 'post_status' => 'publish', 'posts_per_page' => -1, // 'caller_get_posts'=> 1 );  $my_query = null; $my_query = new wp_query($args); if( $my_query->have_posts() ) { // echo 'list of posts titles beginning letter '. $char_a; while ($my_query->have_posts()) : $my_query->the_post(); ?>     <p><a href="<?php the_permalink() ?>" rel="bookmark" title="permanent link <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>    <?php endwhile; } wp_reset_query(); } ?> 



this tried change in end of code

    <?php } endwhile; else : ?> <p><?php _e( 'sorry, no posts matched criteria.' ); ?></p> 



i tried change this

<?php endwhile; } else : ?> <p><?php _e( 'sorry, no posts matched criteria.' ); ?></p> 

i keep on getting error message

parse error: syntax error, unexpected 'else' (t_else)

how can solve ?

you cannot mix if { } else { } blocks , if: else: endif; blocks in php. since if uses curly braces, else must use curly braces. try this:

<?php endwhile; } else { ?>     <p><?php _e( 'sorry, no posts matched criteria.' ); ?></p> <?php } wp_reset_query(); } ?> 

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -