Bird
0
0

You want to create a plugin that adds a custom greeting only on the homepage without changing core files. Which approach best uses plugins to extend functionality safely?

hard📝 Application Q15 of 15
Wordpress - Plugins and Extensibility
You want to create a plugin that adds a custom greeting only on the homepage without changing core files. Which approach best uses plugins to extend functionality safely?
AUse add_action with 'wp_head' hook and check if is_front_page() before printing greeting
BDirectly edit the header.php file in the theme to add the greeting
CModify WordPress core index.php to include the greeting
DAdd the greeting text inside the WordPress database manually
Step-by-Step Solution
Solution:
  1. Step 1: Avoid core and theme file edits

    Editing core or theme files risks breaking updates and is not safe.
  2. Step 2: Use plugin hooks with conditional check

    Using add_action on 'wp_head' and checking is_front_page() adds greeting only on homepage safely.
  3. Final Answer:

    Use add_action with 'wp_head' hook and check if is_front_page() before printing greeting -> Option A
  4. Quick Check:

    Safe plugin uses hooks and conditionals [OK]
Quick Trick: Use hooks with conditionals to add features safely [OK]
Common Mistakes:
  • Editing core or theme files directly
  • Adding content manually in database
  • Not using conditional checks for homepage

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes