WordPress.org

Ready to get started?Download WordPress

Forums

wp_query class need five queries to database? (1 post)

  1. lostheaven0809
    Member
    Posted 1 year ago #

    i used wp_query class to get posts from a lot of different categories. after that, i checked and my web need 187 queries to database. it echo result in the footer tag. you can see at the Menu section in footer. it's terrible. i found out wp_query class need 5 query to database when it runs. is it right?
    what function i recommend to use when i want to get posts from a lot of different categories?

    $query = new WP_Query(array('posts_per_page' => 10, 'category_name' => 'tin-tuc'));
    ....
    wp_reset_postdata();
    $query = new WP_Query(array('posts_per_page' => 10, 'category_name' => 'tai-lieu'));
    ....
    wp_reset_postdata();

    and a lot of alike snippets. i get all of them out and then put into one by one. i found out every snippet need 5 query to database.

    i design my theme by myself. not use any outside plugin.
    help me. thanks

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags