Load ajax if is_home()

Use: if ( is_home() or ( defined( ‘DOING_AJAX’ ) && DOING_AJAX ) ) is_home() returns TRUE on the front-end only, admin-ajax.php on the other hand is an admin page. So you need to check both conditions.

Get log of function/method calls made by do_action() on WordPress initialization

I don’t believe there is a way to do this via a plugin (at least in a way that will get around 500 type errors, which is why I originally looked into this), but the section of code where the hook callback gets called is in wp-includes/plugin.php in the do_action function: https://github.com/WordPress/WordPress/blob/master/wp-includes/plugin.php#L453 This got updated … Read more

Stop WordPress Entirely and Run My Own Code

You could hook init and check the current blog ID function wpa85780_my_app_init(){ $my_blog_id = 99; if( $my_blog_id == get_current_blog_id() ): include ‘somefile’; exit; endif; } add_action( ‘init’, ‘wpa85780_my_app_init’ ); This will exit before WordPress does the main query and loads the template. EDIT a slightly earlier action you could hook is after_setup_theme, that seems to … Read more

What is the entry point of a WordPress theme?

The active theme’s functions.php is the first theme file loaded, in the file wp-settings.php. All other theme files are loaded depending on the context of the request, which happens very late in the load process, after the user is authenticated, the request is parsed, and the query runs. Templates are for display, nothing belongs in … Read more

How to insert a text in all pages and posts before or after specific places?

You can add to before or after the content as well in a similar fashion. I use this code: function rt_before_after($content) { $beforecontent=”This goes before the content.”; $aftercontent=”And this will come after.”; $fullcontent = $beforecontent . $content . $aftercontent; return $fullcontent; } add_filter(‘the_content’, ‘rt_before_after’); You could use it similarly with the_title,. The reko_hook() you have … Read more

Cron While Editing Post

It seems to have solved by changing the two functions, by taking a different approach: /* CHECK IF CURRENT USER IS NOT IN POST.PHP AND IN POST-NEW.PHP AND DOWNGRADE PUBLISH POSTS IN PENDING AFTER X DAYS */ if(is_admin() ) {global $pagenow; if( ‘post.php’ != $pagenow || ‘post-new.php’ != $pagenow) { add_action( ‘init’, ‘downgrade_publish_posts’ ); function … Read more

WordPress Plugin Boilerplate – add_action hook in static “activate” function

The problem is the initialization in WordPress via register_activation_hook( __FILE__, ‘activate_IWCollege_Courses’ ); The function was fired on the Activation of a plugin, not more. You must switch to the hook init. For Custom Post types, the init hook is recommended in the codex. Custom post types must be registered during every WordPress initialization. But the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)