Unable to view blog in order=ASC in wordpress.

Asked 1 years ago, Updated 1 years ago, 86 views

I would like to show my blog in order=ASC in Wordpress, but I can do it in the first loop, but not in the second loop.There should be two articles, but only one is displayed.Please tell me what to do! Thank you for your cooperation.

<?php

get_header(); ?>
<!--site-content-->
<div class="site-content clearfix">

        <?php

        if(have_posts()):
            while(have_posts())—the_post();

            the_content();
            endwhile;
            else:
                echo'<p>No content found</p>';
         endif;

            // opion posts loop begins here
            $testPosts=newWP_Query('cat=4&posts_per_page=2&orderby=title&order=ASC');

        if($testPosts->have_posts()):
            while($testPosts->have_posts()): 
                $testPosts->the_post();?>
            <h2><?php the_title();?>/h2>
            <?php
            endwhile;
            else:
                echo'<p>No content found</p>';
        endif;
        wp_reset_postdata();

        echo'i';

        // opion posts loop begins here
            $newsPosts=newWP_Query('cat=9&posts_per_page=2&orderby=title&order=ASC');

        if($newsPosts->have_posts()):
            while($newsPosts->have_posts()): 
                $newsPosts->the_post();?>
            <h2><?phpecho get_the_title();?>/h2>
            <?php
            endwhile;
            else:
                echo'<p>No content found</p>';
        endif;
        wp_reset_postdata();
        ?>

</div><!--/site-content-->
<?php get_footer();

?>

wordpress

2022-09-30 21:17

1 Answers

The first article did not have a title and could not be displayed.


2022-09-30 21:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.