Why, Where, and When to use reference pointers in filters/hooks?

The example you give is used when you’re building a plugin/theme using a class. In normal use, your functions.php file would just have: function my_function_to_filter( $args ) { // … function stuff here return $args; } add_filter(‘some_wp_filter’, ‘my_function_to_filter’); If you’re using a class, though, things would look different. You’d likely have a my-class.php file containing: … Read more

Check php version before theme activation

As you want to implement the check within your theme files you can use the action after_switch_theme; as you can guess this will activate your theme to perform the check but will switch back to the previous theme if necessary. If the requirements are not fulfilled we’re going to notify the user via an admin … Read more

When and Where to use wp_insert_post()

Use some type of conditional tag to check if those posts exist or not. If they do not exist, have them created with wp_insert_post. Do this logic inside the AddMyPages function and not around the add_action function. Example You want to add a page with a parent ID only if it does not exist, and … Read more