Search test library by skills or roles
⌘ K

Adaface Sample WordPress Questions

Here are some sample WordPress questions from our premium questions library (10273 non-googleable questions).

Skills

🧐 Question

Medium

Custom WordPress Shortcode
Shortcodes
Solve
You're creating a custom WordPress shortcode that users can insert into their posts and pages to display a promotional banner. Your initial PHP code is as follows:
 image
A user inserts your shortcode into a post like this:
 image
However, when the user previews the post, the content inside the `[promo-banner]` shortcode isn't displayed. Instead, the user sees the shortcode itself.
            
            What change can you make to fix this issue?
A: Replace `'promo-banner'` with `'[promo-banner]'` in the `add_shortcode` function.
            B: Replace `'promo-banner'` with `'[promo-banner]'` in the shortcode inserted into the post.
            C: Change the `promo_banner_shortcode` function to accept only one parameter.
            D: Use `do_shortcode` function to process the `$content` inside the `promo_banner_shortcode` function.
            E: Replace `$content` with `$atts['content']` in the `promo_banner_shortcode` function.

Medium

Iteration in WordPress Plugin
Asynchronous JavaScript
Solve
You're developing a WordPress plugin where you need to fetch comments for a list of posts from a WordPress database using AJAX. The JavaScript code is as follows:
 image
The processComments function processes the comments for other operations and is working as expected.
            
            However, when running the code, you notice that the console logs for fetched comments don't appear in the order of the post IDs. Instead, the logs appear in a seemingly random order each time.
            
            What change can you make to ensure the comments are fetched and processed in the order of the post IDs?
A: Use a traditional for loop instead of forEach.
            B: Use setTimeout to delay the execution of fetchComments.
            C: Use sort on postIDs before calling forEach.
            D: Change forEach to map and use Promise.all.
            E: Make processComments function asynchronous and await it in the forEach loop.

Medium

Responsive load
Optimization
Solve
Here’s the code snippet of interest from a client's WordPress code:
 image
 image
You are reviewing the client's code and have to make recommendations to improve speed of the WordPress site. Which of these are good recommendations?
A: Cache the website to improve the site but need to move the responsive logic to CSS. The conditional logic might not be cached if the cache provider does not trigger the conditionals
            
            B: Cache the website to improve the site. No need to move the responsive logic to CSS
            
            C: jQuery is very commonly loaded on live sites multiple times due to poorly written plugins/themes. Ensure required JS files are enqueued only once and when they are needed
            
            D: CSS in <head> file will affect the speed of the site since the entire CSS file has to be loaded before rendering the site. It is advised to load only the CSS that is mandatory in the <head> and move the rest of the CSS to the later portions of the HTML

Medium

Shortcode Development in WordPress
Shortcodes
WP_Query
Loop
Solve
You're developing a WordPress plugin that provides a shortcode to display the latest posts. The shortcode is [latest-posts count="3"], where the "count" attribute determines the number of latest posts to display. 
            
            Your initial PHP code is as follows:
 image
You test the shortcode on a page and find that the page content following the shortcode doesn't display.
            
            What change can you make to fix this issue?
A: Use `return $query->have_posts();` instead of `$query->the_post();`.
            B: Use `wp_reset_query();` after the while loop.
            C: Use `the_content();` after the while loop.
            D: Use `wp_reset_postdata();` after the while loop.
            E: Use `return $output;` before the while loop.

Medium

WP REST API
REST API
HTTP Requests
JSON Response
Solve
You're developing a custom WordPress plugin to fetch and display a list of posts using the WordPress REST API. Your initial JavaScript code is as follows:
 image
This code works fine when the website URL is `http://localhost/wordpress`. However, when you move your website to a different domain (for example, `http://example.com`), the list of posts doesn't display.
            
            What change can you make to fix this issue?
A: Replace `/wp-json/wp/v2/posts` with `http://example.com/wp-json/wp/v2/posts`.
            B: Replace `/wp-json/wp/v2/posts` with `http://localhost/wordpress/wp-json/wp/v2/posts`.
            C: Use `wp_localize_script` to pass the website URL from PHP to JavaScript, and prepend it to `/wp-json/wp/v2/posts`.
            D: Use `admin_url('admin-ajax.php')` to replace `/wp-json/wp/v2/posts`.
            E: Use `site_url('/wp-json/wp/v2/posts')` to replace `/wp-json/wp/v2/posts`.
🧐 Question🔧 Skill

Medium

Custom WordPress Shortcode
Shortcodes

2 mins

WordPress
Solve

Medium

Iteration in WordPress Plugin
Asynchronous JavaScript

3 mins

WordPress
Solve

Medium

Responsive load
Optimization

3 mins

WordPress
Solve

Medium

Shortcode Development in WordPress
Shortcodes
WP_Query
Loop

2 mins

WordPress
Solve

Medium

WP REST API
REST API
HTTP Requests
JSON Response

2 mins

WordPress
Solve
🧐 Question🔧 Skill💪 Difficulty⌛ Time
Custom WordPress Shortcode
Shortcodes
WordPress
Medium2 mins
Solve
Iteration in WordPress Plugin
Asynchronous JavaScript
WordPress
Medium3 mins
Solve
Responsive load
Optimization
WordPress
Medium3 mins
Solve
Shortcode Development in WordPress
Shortcodes
WP_Query
Loop
WordPress
Medium2 mins
Solve
WP REST API
REST API
HTTP Requests
JSON Response
WordPress
Medium2 mins
Solve

Trusted by recruitment teams in enterprises globally

Amazon Morgan Stanley Vodafone United Nations HCL PayPal Bosch WeWork Optimum Solutions Deloitte Microsoft NCS Doubtnut Sokrati J&T Express Capegemini

We evaluated several of their competitors and found Adaface to be the most compelling. Great library of questions that are designed to test for fit rather than memorization of algorithms.


Swayam Narain, CTO, Affable

hashtag image heart icon Swayam
customers across world
Join 1200+ companies in 75+ countries.
Try the most candidate friendly skills assessment tool today.
g2 badges
Ready to streamline your recruitment efforts with Adaface?
Ready to streamline your recruitment efforts with Adaface?
logo
40 min tests.
No trick questions.
Accurate shortlisting.
ada
Ada
● Online
Previous
Score: NA
Next
✖️