Articles of hooks

How to return the values from a row where a value occurs for the first time among the rows available?

I have a database table in WordPress as in the following example: ID | Allocation_number | Treatment | Used 1 | 1 | A | 0 2 | 2 | B | 0 3 | 3 | B | 0 4 | 4 | A | 0 And the rows continues upto X times. The […]

Is There A WordPress Hook for Accessing Attachments for A Particular Page?

I’m writing a site with a category that’s used for formatting specific types of reports. The user logs in, and writes the report as a blog entry. When they select the category, the report is formatted in a certain way. I’m editing the “single.php” file in my child theme (I’m deriving from WooCommerce mystile) What […]

Add child pages to submenu automatically

If a new page is added under a parent page (front end), which is part of a nav menu, I want the new page to be added to the appropriate submenu automatically – without any plugin. Reason: A custom user role has all caps to add, edit, delete posts and pages. However, this role shall […]

Filter yoast canonical add_action priority

I’m trying to look around over Google of how to hook the add_action and change the priority of Yoast Canonical, from: 20 add_action( ‘wpseo_head’, array( $this, ‘canonical’ ), 20 ); to: 55 add_action( ‘wpseo_head’, array( $this, ‘canonical’ ), 55 ); This affect the position from the frontend head tag section. Is there a way to […]

What hook should I use that will fire whenever I open a post for editing in the WP back-end?

I’d like to create a simple action hook that fires whenever I open a post for editing in the WordPress back-end. What hook(s) can/should I use for this? The action would just be a simple echo command that prints text to the screen (as this is only for testing purposes). Thanks.

Hook function prints output twice

I have started learning Hooks today and trying to accomplish the following. When the home page of my site loads, it would insert a new term in my custom taxonomy called amenities. Then using a dynamic Hook (create_{$taxonomy}, in my case it is create_amenities) and with the help of a custom function hooked into create_amenities […]

wp_login Action hook with conditional tag

i tried to create a simple function to receive a email when a specify user is logged, i tried with $current_user->ID and also with wp_get_current_user() but not working. This is my code: function InvioMail() { global $current_user; $ID = $current_user->ID; $user = wp_get_current_user(); $name = $user->user_login; if ($name == ‘piero’) { $to = ‘example@mail.com’; $subject […]

Woocommerce table is missing a heading–can I add it by use of a hook?

My Woocommerce shopping cart page displays a column for my product thumbnails, but the heading of the column is missing (screenshot). Can I add a heading here by using a filter hook? If so, can anyone suggest the particular hook to use? I’ve looked through the big book of Woocommerce hooks, but can’t seem to […]

Combining several CSS files into one for optimization

I have an idea. And I hope it is already implemented somehow. Here is an example of CSS files in the head of a page <link rel=’stylesheet’ id=’validate-engine-css-css’ href=’https://example.net/wp-content/plugins/wysija-newsletters/css/A.validationEngine.jquery.css,qver=2.7.10.pagespeed.cf.jcn-RfgU3K.css’ type=’text/css’ media=’all’/> <link rel=’stylesheet’ id=’cresta-social-crestafont-css’ href=’https://example.net/wp-content/plugins/cresta-social-share-counter/css/A.csscfont.css,qver=2.6.8.pagespeed.cf.g-Qv5WAJKD.css’ type=’text/css’ media=’all’/> <link rel=’stylesheet’ id=’cresta-social-wp-style-css’ href=’https://example.net/wp-content/plugins/cresta-social-share-counter/css/A.cresta-wp-css.css,qver=2.6.8.pagespeed.cf.cfwDMPSSsV.css’ type=’text/css’ media=’all’/> <link rel=’stylesheet’ id=’cresta-social-googlefonts-css’ href=’//fonts.googleapis.com/css?family=Noto+Sans:400,700′ type=’text/css’ media=’all’/> <link rel=’stylesheet’ id=’dashicons-css’ href=’https://example.net/wp-includes/css/dashicons.min.css,qver=4.7.5.pagespeed.ce.zzwOjyb-IC.css’ type=’text/css’ media=’all’/> […]

the_post hook is not firing for me

I have a super simple requirement here. I have added a meta field to all posts that will allow a url to be used to redirect the post (i have reasons for doing it this way). I am trying to trigger this on the action “the_post”, but for some reason it doesnt seem to fire. […]