1

My posts where showing for a while but now they are gone from my page. I see no mistakes and there's no error messages in debug mode, I really don't know why wouldn't my posts show with this code, specially when it was working before. All I did was add the Advanced Custom Fields plugin, add a few fields, link them to my posts and save. Then my posts were gone. I have disabled and deleted the plugin, remade all my posts but nothing works.

                <div class="artiq-slidder">

                        <ul class="artiq-slidder-ul">

                            <?php

                                $args = array(
                                        "post_type" => "piso"
                                );
                                $the_query = new WP_Query( $args );

                            ?>

                            <?php if( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

                                <li class="artiq-slidder-item">


                                <img src="<?php the_post_thumbnail(); ?>">  

                                     <a href="<?php the_permalink(); ?>">
                                        <p> <?php the_title(); ?> </p>
                                      </a>
                                </li>

                            <?php endwhile; endif; ?>


                        </ul>

                    </div>
  • 1
    Are the posts showing in the admin? Maybe you accidentally changed the post name along the way? The edit.php page in the admin will show the post type. e.g. http://example.com/wp-admin/edit.php?post_type=piso Also, in what template does this code appear? Would you edit your question and include the whole template? What is the page/post that you are looking at and what's the URL? Also, small correction to your code, it should be if ( $the_query->have_posts() ) : – Dave Romsey May 9 '17 at 20:29
  • This topic is duplicate of wordpress.stackexchange.com/questions/266404/… – Vinod Dalvi May 10 '17 at 7:17
2

please try this:

 <?php if( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

Thank you

  • 1
    Please edit your answer, and add an explanation: why could that solve the problem? – fuxia May 16 '17 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.