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.
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.
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
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
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
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
According to the docs, I needed to set the terms using post ID. So after every insert, I used the ID to set the terms https://codex.wordpress.org/Function_Reference/wp_set_post_terms Someone might find this useful.
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
What is the best filter where to use register_block_type?
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
The problem with your code is pretty simple. You don’t terminate the script execution after doing redirect. So the header will be set, but browser will ignore it. If you’ll take a look at WP Code Reference, there is clearly stated: Note: wp_redirect() does not exit automatically, and should almost always be followed by a … Read more