PHP and Wordpress Integration Flashcards
Q: What is the primary role of PHP in WordPress?
A: To process data, interact with the database, and generate dynamic HTML for web pages.
Q: What is the name of the WordPress core PHP configuration file?
A: wp-config.php.
Q: What global object is used to interact with the database in WordPress?
A: $wpdb.
Q: How do you include a PHP file in a WordPress theme?
A: Use get_template_part() or require_once().
Q: How do you add PHP code to a WordPress page or post?
A: Use a plugin like “Insert PHP Code Snippet” or write a custom shortcode.
Q: How do you define a WordPress theme?
A: By creating a directory in /wp-content/themes/ with at least style.css and index.php.
Q: What function is used to enqueue styles in a theme?
A: wp_enqueue_style().
Q: What function is used to enqueue scripts in a theme?
A: wp_enqueue_script().
Q: How do you add a theme support feature, like post thumbnails?
A: Use add_theme_support().
Q: What PHP function outputs the content of the <title> tag?</title>
A: wp_title() (deprecated, use add_theme_support( ‘title-tag’ ) instead).
Q: What is the minimum requirement for a WordPress plugin?
A: A PHP file with a plugin header comment.
Q: How do you add an admin menu in a plugin?
A: Use add_menu_page() or add_submenu_page().
Q: How do you register a plugin’s custom settings?
A: Use register_setting().
Q: How do you enqueue plugin-specific scripts or styles?
A: Use wp_enqueue_scripts or admin_enqueue_scripts.
Q: What PHP function activates a WordPress plugin?
A: Use the register_activation_hook() function.
Q: What is an action hook in WordPress?
A: A point in the WordPress execution where a function can be hooked to perform an action.