Complete the code to get the value of a query parameter named 'page'.
$page = $_GET[[1]];In WordPress and PHP, query parameters are accessed via the $_GET superglobal array. To get the 'page' parameter, use $_GET['page'].
Complete the code to check if the 'category' query parameter exists.
if (isset($_GET[[1]])) { // do something }
The isset() function checks if a variable is set and not null. To check if the 'category' query parameter exists, use isset($_GET['category']).
Fix the error in the code to safely get the 'author' query parameter or set it to 'guest' if missing.
$author = $_GET[[1]] ?? 'guest';
The null coalescing operator ?? returns the left value if it exists and is not null; otherwise, it returns the right value. To get 'author' or default to 'guest', use $_GET['author'] ?? 'guest'.
Fill both blanks to create a query that gets posts filtered by 'tag' and ordered by 'date'.
$args = array(
'tag' => $_GET[[1]],
'orderby' => [2]
);To filter posts by the 'tag' query parameter, use 'tag' => $_GET['tag']. To order posts by date, set 'orderby' => 'date'.
Fill all three blanks to build a WP_Query args array filtering by 'author', limiting posts to 5, and ordering by 'title'.
$args = array(
'author_name' => $_GET[[1]],
'posts_per_page' => [2],
'orderby' => [3]
);To filter by author from query parameters, use $_GET['author']. Limit posts to 5 with 'posts_per_page' => 5. Order by title with 'orderby' => 'title'.