Add filter return false not working

Instead of adding the filter inside of the add_action(), you need to call the filter directly. You have this in your functions.php file: function filter_after_setup_theme() { add_filter( ‘tc_bridge_for_woocommerce_content_order_table_is_after’, ‘__return_false’ ); } add_action(‘after_setup_theme’, ‘filter_after_setup_theme’); You are telling to WordPress to execute the filter when the action after_setup_theme happens (which is called before init hook, according to … Read more

Remove style tags from head

My solution removes now all <link></link> tags and <style>@import url()</style> googleapi entries in the given HTML: add_action( ‘wp_footer’, ‘SPDSGVOPublic::removeGoogleFonts’ ); /** * Remove all occurrences of google fonts */ public static function removeGoogleFonts() { ob_start(); $content = ob_get_clean(); $patternImportUrl=”/(@import[\s]url\((?:”|\”)((?:https?:)?\/\/fonts\.googleapis\.com\/css(?:(?!\1).)+)(?:”|\’)\)\;)/’; $patternLinkTag = ‘/<link(?:\s+(?:(?!href\s*=\s*)[^>])+)?(?:\s+href\s*=\s*([\'”])((?:https?:)?\/\/fonts\.googleapis\.com\/css(?:(?!\1).)+)\1)(?:\s+[^>]*)?>/’; preg_match_all($patternImportUrl, $content, $matchesImportUrl); preg_match_all($patternLinkTag, $content, $matchesLinkTag); $matches = array_merge($matchesImportUrl,$matchesLinkTag); foreach( $matches as $match … Read more

Archive Widget – Count only parent posts

I haven’t tested this, but I found a sample that was close. I have modified it to be similar to what you want. I’m not sure it is 100%, but it should get you really close: add_action(‘pre_get_posts’,’wpse_filter_parents_only’); function wpse_filter_parents_only($query){ if (!is_admin() && is_category(’26’)){ $query->set(‘post_parent’,0); } return $query; } This should update what WP_Query retrieves from … Read more

Changing title using filter not working with argument

Maybe you can add a higher priority to your filter as the 3rd parameter of the hook: /** * Modify the data * * @param String $data * * @return String $data */ function change_title( $data ) { global $post; return ‘Page ID ‘ . $data; } add_filter( ‘the_title’, ‘change_title’, 15 ); The default priority … Read more

Unable to defer loading of jquery

add_filter( ‘script_loader_tag’, function ( $tag, $handle ) { $handlesToDefer = array(‘jquery-migrate’, ‘bootstrap’, ‘jquery-core’); if ( !in_array($handle, $handlesToDefer) ) return $tag; return str_replace( ‘ src’, ‘ defer=”defer” src’, $tag );

Display posts from today and future in Elementor ‘posts widget’

Here is the working solution: add_action( ‘elementor/query/my-custom-query’, function( $query ) { $meta_query = $query->get( ‘meta_query’ ); $query->set( ‘date_query’, array( array( ‘after’ => date(‘l, F jS, Y’, strtotime(‘+0 day’)), ) ) ); } ); You can change the strtotime (+1 day….+n day ….-n day) to fetch the event’s date you’re looking for. The date format here … Read more

Modify Contextual Help

If you want to remove some or all (default) help tabs, then you could do something like this inside your function. $current_screen = get_current_screen(); $white_list = array( ‘overview-link’, // If you want to keep default some tab title and content ); if ( $current_tabs = $current_screen->get_help_tabs() ) { foreach ($current_tabs as $tab_key => $tab_config) { … Read more

Distinguish between page and post in function

By using post id you can get post type of current post/page. try below code. i have tested and it is working fine for me. add_filter( ‘admin_post_thumbnail_html’, ‘foo’,10,3 ); function foo( $content, $post_id, $thumbnail_id ) { if ( get_post_type( $post_id ) == ‘page’ ) { $content=”<p>foobar</p>” . $content; } else{ $content=”<p>barfoo</p>” . $content; } return … Read more

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