Use $query->set multiple times with pre_get_posts?

Think of this pseudo code if sky == blue set a = 5 if grass == green set a = 7 What value will a have? Not 12. This is the exact same situation. You are setting a specific parameter to a specific value. In the second call, you are overwriting your previous value. To … Read more

Redirect logged in users if they are on a specific page

One problem is that you’re hooking in too early. Reference the Hooks API Action Reference. Template conditionals such as is_page() are only available after the query has been set up and parsed. The earliest action that you can usually safely rely on query conditionals is pre_get_posts. You’re hooking into init, which fires much earlier: muplugins_loaded … Read more

Hook/notify when any option or setting is added or updated

Looking at the sources (core files, wp-includes/option.php) you can always find your target hook tags: add_action(‘added_option’, ‘wpse230212_callback_add’, 10, 2); add_action(‘updated_option’, ‘wpse230212_callback_update’, 10, 3); function wpse230212_callback_add( $option_name, $option_value ) { // do stuff on add_option } function wpse230212_callback_update( $option_name, $old_value, $option_value ) { // do stuff on update_option } Hope that helps.

Difference between hooks Plugin_loaded and admin_int?

plugins_loaded fires once activated plugins have loaded. This fires on both admin and public screens. admin_init fires as an admin screen or script is being initialized. This fires only on admin screens. The typical order for firing of hooks on the admin screen is: muplugins_loaded – this is the first hook available to must-use plugins … Read more

WordPress Admin Tooltip hooks

Here is the simplest implementation I know of since there is no real API: //add the needed scripts and styles add_action(‘admin_enqueue_scripts’, ‘wpse_46028_enqueue_admin_scripts’); function wpse_46028_enqueue_admin_scripts() { wp_enqueue_style(‘wp-pointer’); wp_enqueue_script(‘wp-pointer’); //hook the pointer add_action(‘admin_print_footer_scripts’, ‘wpse_46028_print_footer_scripts’ ); } function wpse_46028_print_footer_scripts() { $pointer_content=”<h3>WordPress Answers</h3>”; $pointer_content .= ‘<p>This is your pointer content</p>’; ?> <script type=”text/javascript”> //<![CDATA[ jQuery(document).ready( function($) { //jQuery selector … Read more

Disable block from editor based on post type

You can use the allowed_block_types hook: <?php function wpse_allowed_block_types($allowed_block_types, $post) { // Limit blocks in ‘post’ post type if($post->post_type == ‘post’) { // Return an array containing the allowed block types return array( ‘core/paragraph’, ‘core/heading’ ); } // Limit blocks in ‘page’ post type elseif($post->post_type == ‘page’) { return array( ‘core/list’ ); } // Allow … Read more

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