Articles of filters

Namespaced action and filter tags

I’m upgrading several of my plugins to use PHP namespaces, so that functions, classes, constants etc are all namespaced correctly. <?php namespace my\plugin; function init() { … } // Calls \my\plugin\init(); add_action(‘init’, __NAMESPACE__.’\init’); In several places my plugin calls do_action or apply_filters so that other plugins can modify its behaviour. If these are actions or […]

What hook/filter can I use to add/edit/show/hide the title under (on hover) links on the table view?

I’m not entirely sure the name given to these links, but the class is called “row-actions”.

WordPress php filter admin_body_class not working

I have the following function in a plugin I have built: static function filter_add_body_classes( $body_classes ) { $new_classes = array(); // Only when logged in if ( ! is_user_logged_in() ) { return $body_classes; } // If viewing the site if ( ! is_admin() ) { $new_classes[] = ‘sat-site’; } // If theming is enabled if […]

WordPress after content Hook & external template part

I am trying to use this method to include a template part (HTML Code) rather than using some plain text. When I use text, it shows correctly below the content with the the_content filter. However, If I try to get_template_part, the content shows at the top of the WordPress post rather than below the content. […]

How to add #navbar to all page links?

I have several WordPress websites with large images at their tops, using 2013 child theme. How to add #navbar anchor to all page links, so that the browser scrolls down a bit, when a user clicks a link in the Pages widget? (because otherwise users think that nothing has happened after they click, since they […]

Function the_content not working

I’m developing a site with the Advanced Custom Fields and SF Taxonomy Thumbnail. In any page (post type = page), I’m with an error that I don’t know what is happening: My custom template code: https://gist.github.com/gabfr/79e1c915d0b2f9ed6620aee7fdc8c8b0 (similar to the page.php) I don’t have custom filters in my function.php, and I already tried to deactivate the […]

How to get list of all hooks of current theme / plugin?

I want to get the list of all available hooks from active theme / from a specific plugin. I was tried to get it from global variables $wp_actions & $wp_filter But, They are showing all registered hooks. E.g. global $wp_actions, $wp_filter; echo ‘<pre>’; print_r($wp_filter); E.g. If theme or plugin register the action in after_setup_theme then […]

Query total number of posts

Using a search filter plugin. I am using to get the total number of posts that exist in the database $wp_query->found_posts However, when a user filters the results on the page, this number changes according to how many posts are shown on the filter. How could I get the static total number of posts which […]

Is there a get_post(s) filter that can alter/replace the output completely?

I would like to create a plugin that creates a JSON cache of saved/updated data. But for the plugin to be general purpose I’d need it to override the output of get_posts and other get_functions. I know that html cache is faster and that good plugins already exist for that purpose, but this would be […]

Add Sortable Column For All Post Types

I am creating a hit counter that counts the number of page views across all post types. I have gotten it to work and the column displays for each post type showing the total number of page views. I was able to get the column to show up for every post type by using the […]