Hook into $wpdb

query – you will get sql as argument of the callback. add_filter(‘query’, ‘some_callback_that_change_query’); function some_callback_that_change_query($sql){ remove_filter(‘query’, ‘some_callback_that_change_query’); // your banny wrote add_filter(‘query’, ‘some_callback_that_change_query’); return $sql; }

Send data to 3rd party api with wp_remote_post on wp_login

The ‘body’ needs to be an array, not including the ‘json_encode($user)’ piece. $response = wp_remote_post( ‘myapp.com/endpoint’, array( ‘method’ => ‘POST’, ‘headers’ => array(‘Content-Type’ => ‘application/json; charset=utf-8’), ‘body’ => $user ) ); I have this in my function since I also had issues with the body being an object: if (is_object($user) && !is_array($user)) $user = json_decode(json_encode($user), … Read more

Remove title attribute from images

I would strongly discourage this. A better, more sustainable practice would be to educate your clients on the value of the title attribute and teach them how to use it properly. Simply removing it is putting a bandage on the symptom, not combating the disease. However, if you do want to remove the attribute anyway, … Read more

why doesnt is_home() work in functions.php

At the time functions.php is included during bootup, WordPress has no idea on the contents of the query, and doesn’t know the nature of the page. is_home will return false. Wrap the code in a function and have it triggered by the wp hook, which comes after the global query object has been hydrated with … Read more

Hook into wp_head(); in a plugin

Did you try this? function hook_header() { $example_position = get_theme_mod( ‘logo_placement’ ); if( $example_position != ” ) { switch ( $example_position ) { case ‘left’: // Do nothing. The theme already aligns the logo to the left break; case ‘right’: echo ‘<style type=”text/css”>’; echo ‘#main-header #logo{ float: right; }’; echo ‘</style>’; break; case ‘center’: echo … Read more

Replace Dashes Before Title in Page List

You can’t change dashes using any filter because there is no filter available to change it. but still you can change this using jQuery put this code inside functions.php add_action(‘admin_head’,function(){ global $pagenow; // check current page. if( $pagenow == ‘edit.php’ ){ ?> <script> jQuery(function($){ var post_title = $(‘.wp-list-table’).find(‘a.row-title’); $.each(post_title,function(index,em){ var text = $(em).html(); // Replace … Read more

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