0
0
Wordpressframework~10 mins

Query optimization in Wordpress - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to get posts with the latest date first.

Wordpress
$args = array('post_type' => 'post', 'orderby' => '[1]');
Drag options to blanks, or click blank then click option'
Adate
Btitle
Cauthor
Dcomment_count
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'title' instead of 'date' will sort alphabetically.
Using 'author' will sort by author name, not date.
2fill in blank
medium

Complete the code to limit the query to 5 posts.

Wordpress
$args = array('posts_per_page' => [1]);
Drag options to blanks, or click blank then click option'
A5
B10
C0
D-1
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 or -1 will show all posts, not limit.
Using 10 will show more posts than needed.
3fill in blank
hard

Fix the error in the query argument to exclude sticky posts.

Wordpress
$args = array('post_type' => 'post', 'ignore_sticky_posts' => [1]);
Drag options to blanks, or click blank then click option'
A'false'
Bfalse
Ctrue
D'true'
Attempts:
3 left
💡 Hint
Common Mistakes
Using strings like 'true' or 'false' instead of boolean values.
Using false will include sticky posts.
4fill in blank
hard

Fill both blanks to query posts from category ID 3 and order by title ascending.

Wordpress
$args = array('cat' => [1], 'orderby' => '[2]', 'order' => 'ASC');
Drag options to blanks, or click blank then click option'
A3
Bdate
Ctitle
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong category ID.
Ordering by 'date' instead of 'title'.
5fill in blank
hard

Fill all three blanks to query posts with meta key 'color', meta value 'blue', and order by meta value ascending.

Wordpress
$args = array('meta_key' => '[1]', 'meta_value' => '[2]', 'orderby' => '[3]', 'order' => 'ASC');
Drag options to blanks, or click blank then click option'
Acolor
Bblue
Cmeta_value
Ddate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'date' instead of 'meta_value' for ordering.
Mixing up meta key and meta value.