Lubinik Learning

Training mode

WP_Query, Database & Performance

Time remaining:

0 / 18 answered

  1. 1. What should be called after a secondary loop that uses WP_Query::the_post()?

    $query = new WP_Query( $args );
    while ( $query->have_posts() ) {
        $query->the_post();
        the_title();
    }
    What should be called after a secondary loop that uses WP_Query::the_post()?
    Hint

    The secondary loop changed the global $post variable.

  2. 2. How should dynamic values be included in a custom SQL query with $wpdb?

    The query contains values supplied at runtime.

    How should dynamic values be included in a custom SQL query with $wpdb?
    Hint

    Do not concatenate untrusted values into the SQL string.

  3. 3. Which values are good candidates for autoloaded options?

    Think about both access frequency and total payload size.

    Which values are good candidates for autoloaded options?
    Hint

    Autoloaded options are loaded on many requests.

  4. 4. What guarantee does a transient expiration provide?

    Consider external object caches as well as the database implementation.

    What guarantee does a transient expiration provide?
    Hint

    An expiration is a maximum lifetime, not a minimum lifetime.

  5. 5. What does relation control in a WP_Query meta_query?

    The query contains more than one metadata condition.

    What does relation control in a WP_Query meta_query?
    Hint

    Think of boolean logic between clauses.

  6. 6. When can no_found_rows improve a WP_Query?

    When can no_found_rows improve a WP_Query?
    Hint

    Do you need max_num_pages?

  7. 7. What is the main limitation of relying on wp_cache_set() for long-term persistence?

    What is the main limitation of relying on wp_cache_set() for long-term persistence?
    Hint

    The default object cache is request-scoped.

  8. 8. What does update_post_meta() do when the meta key does not yet exist?

    What does update_post_meta() do when the meta key does not yet exist?
    Hint

    The function supports both creation and update.

  9. 9. Which WP_Query argument can reduce memory usage when only post IDs are needed?

    Which WP_Query argument can reduce memory usage when only post IDs are needed?
    Hint

    Request only the shape of data you need.

  10. 10. What should a developer remember about WP-Cron timing?

    What should a developer remember about WP-Cron timing?
    Hint

    It is not the operating system cron daemon.

  11. 11. What does posts_per_page => -1 request from WP_Query?

    What does posts_per_page => -1 request from WP_Query?
    Hint

    Use carefully on large datasets.

  12. 12. Which WP_Query argument prevents sticky posts from being promoted?

    Which WP_Query argument prevents sticky posts from being promoted?
    Hint

    It does not exclude sticky posts from matching.

  13. 13. Which WP_Query argument filters posts by taxonomy terms?

    Which WP_Query argument filters posts by taxonomy terms?
    Hint

    Metadata and taxonomy data use different query arguments.

  14. 14. How should a LIKE search value be prepared with $wpdb?

    How should a LIKE search value be prepared with $wpdb?
    Hint

    LIKE escaping and SQL placeholders solve different problems.

  15. 15. Why must code treat get_transient() returning false carefully?

    Why must code treat get_transient() returning false carefully?
    Hint

    Avoid caching a literal false when you must distinguish it.

  16. 16. What is often more efficient for a small related settings group?

    What is often more efficient for a small related settings group?
    Hint

    Keep unrelated or very large values separate.

  17. 17. Why use cache groups with wp_cache_get() and wp_cache_set()?

    Why use cache groups with wp_cache_get() and wp_cache_set()?
    Hint

    A key may be common, such as count.

  18. 18. What is the hard part of caching a database query in a transient?

    What is the hard part of caching a database query in a transient?
    Hint

    Fast stale data may still be wrong.