Change term name only on front

You can detect if you are in the frontend using the function is_admin(), like so: add_filter(‘get_term’, ‘filter_term_name’, 10, 2); function filter_term_name($term, $taxonomy) { // return the term untuched if you are in the admin if( is_admin() ) { return $term; } if ($taxonomy == ‘my-taxonomy’) { // numeric value of term in another taxonomy $meta_value … Read more

De-bloating the page classes

And the answer is like this; I figured the most useful bits for me was something that read like this; <body class=”page my-page page-id-28 template-mypage”> where page is the post type, mypage is the page slug, then the id and finally an elegant form of the template. (my templates are all of the form page-templates/page-mypage.php … Read more

Dropdown filter in custom posts

When using this hook, your function receives two parameters, onde of them is the slug of the current post_type; <?php function my_post_type_filter($post_type) { $post_slug = $post_type; if( $post_slug == ‘the_post_type_slug’) { // Do something } } add_action( ‘restrict_manage_posts’, ‘my_post_type_filter’ ); ?> To learn more about this hook check the Docs.

Filter and modify entry-footer link in twentyseventeen

The category link that you are referring to, that is displayed beneath the single post page content is not added with a filter. It is displayed via a function called twentyseventeen_entry_footer(). If you take a look at the themes files you can find the function on line #59, within the file: /wp-content/themes/twentyseventeen/inc/template-tags.php Here is the … Read more

How to change the order (priority) of registered filters (or actions) (e.g. for the_content)?

If you know the existing callback and priority you can just remove the filters and then add again at a different priority: remove_filter( ‘the_content’, ‘convert_smilies’, 20 ); add_filter( ‘the_content’, ‘convert_smilies’, 30 ); remove_filter( ‘the_content’, ‘capital_P_dangit’, 11 ); add_filter( ‘the_content’, ‘capital_P_dangit’, 20 );

Use add_filter on concatenated string variable

As @Sally mention in the comment. if you want to let others to extend the HTML code. you should also append the new HTML they returning in the filter. Try code below $admin_table_output .= “Item Description: </td><td>”; $admin_table_output = apply_filters(‘tabs_page_static_value’,$admin_table_output); $admin_table_output .= “<input type=”text” name=”name” value=”$name”></td><td> (Optional)</td></tr><tr><td colspan=’4′>”;

Modify a Filters Second Parameter

No this isn’t possible without changing the original code. Filters work on the very first parameter, the other parameters are provided for context. You will need too either get the author to add a filter for the data variable, fork the plugin, or use a competitor. The only exception, is if $data is an object … Read more

check to see if hook is available

No, for this to work reliably you would need to register hooks, which can’t be done. The only way to know if a template triggers a hook is to load the template and find out. There is a solution to your problem, but testing if a hook is available is not that solution.

Filter get_template_part() $args array

There’s no such filter, so what you’re doing is about the best you can do. However, you can optimise a bit by creating functions that wrap the template functions while applying your filter: add_filter( ‘filter_template_part_args’, function( $args, $slug, $name = null ) { $args = wp_parse_args( $args, [ ‘id’ => esc_attr( basename( $slug ) ), … Read more