Remove WPML’s home_url filter

I found that it required removing 4 filters/actions to undo WPML’s home_url modification. Since I didn’t know what else this might break, I ended up changing my site’s logo to use site_url() which in my case was the same, but not changed by WPML. function disable_things(){ remove_filter( ‘page_link’, array( $this, ‘permalink_filter’ ), 1, 2 ); … Read more

Change text of Description in Image Library

Even if is not very flexible filter you can use the gettex hook. Only be aware that this filter runs for every string being translated, so can affect performarce if over-used. To narrow the performance impact you can add it only of admin footer, and remove it just after had use it: add_action(‘admin_footer’, function() { … Read more

Alter only the page title, not the post titles within

I believe that the page title you are talking about is the title from the page from the main query. the_title() filter (and the_content() filter for that matter) targets all the respective template tags regardless of query. To avoid this, target only the main query and the specific page. You can try the following inside … Read more

add class to term_description

this does the trick <?php function add_class_to_term_description($term_description) { echo ‘<div class=”cell”>’ . $term_description. ‘</div>’; } add_filter( ‘term_description’, ‘add_class_to_term_description’ ); ?>

How to override the email function by using filters? [closed]

If Divi theme uses wp_mail() function (which most likely does), you can use the wp_mail filter to pass your own arguments to the function: function filter_divi_mail( $args ) { // Modify the options here $custom_mail = array( ‘to’ => $args[‘to’], ‘subject’ => $args[‘subject’], ‘message’ => $args[‘message’], ‘headers’ => $args[‘headers’], ‘attachments’ => $args[‘attachments’], ); // Return … Read more

Allow Profile HTML for select users

You can hook on an early action and apply the filter for your use case: add_action( ‘load-profile.php’, ‘allow_profile_html_wpse_91564’ ); function allow_profile_html_wpse_91564() { global $current_user; if( ‘2’ == $current_user->ID ) remove_filter(‘pre_user_description’, ‘wp_filter_kses’); } The hook load-$pagenow runs in all default admin pages (i.e., not added by a third party), and it’s declared in the file /wp-admin/admin.php. … Read more

Search content for shortcodes and get parameters

This is working for me $shortcode=”book”; $pattern = get_shortcode_regex(); // if shortcode ‘book’ exists if ( preg_match_all( “https://wordpress.stackexchange.com/”. $pattern .’/s’, $post->post_content, $matches ) && array_key_exists( 2, $matches ) && in_array( $shortcode, $matches[2] ) ) { $shortcode_atts = array_keys($matches[2], $shortcode); // if shortcode has attributes if (!empty($shortcode_atts)) { foreach($shortcode_atts as $att) { preg_match(‘/id=”(\d+)”https://wordpress.stackexchange.com/”, $matches[3][$att], $book_id); // … Read more

How can I hide all posts that don’t have a thumbnail?

What filter / hook should I use? You can use the pre_get_posts action hook. Following Tom’s comment on the question about querying for what you want, maybe set meta_query to _thumbnail_id. I would also ( group ) the conditionals to read: “Is both not admin and is main query, AND is either home, category, or … Read more

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