How to add a custom filter in functions.php

To be honest, I had to actually see the source code to get the correct answer for you. The problem with this particular filter is that the $filter part is dynamic and thus you have to know what particular frequency you want to modify. There’s a numerous of options: homepage, blogpage, $post_type . ‘_archive’, $post_type … Read more

Filter all html output

You can’t protect against everything a user will do. What if they hard-code an email address in the footer/header/sidebar of their theme? The only way to capture and escape that is with output buffering … and that can become a performance nightmare. My recommendation would be to do two things: Hook in to all of … Read more

Use content custom filter for all shortcodes

so I would like to execute a filter or something that works on every shortcode Looks like you’re after do_shortcode_tag. It “Filters the output created by a shortcode callback.”. Aurovrata Venet gives a demo usage similar to: add_filter( ‘do_shortcode_tag’,function ($output, $tag, $attr){ //make sure it is the right shortcode if(‘aShortcode’ != $tag){ return $output; } … Read more

Apply the_title filter to post titles AND backend auto social-sharing plugin, but not nav menu

Solution function append_album_review_to_title( $title, $id = NULL ) { if ($id) { if ( get_post_type( $id ) == ‘album_review’ ){ return ‘Album Review: ‘ . $title; } else { return $title; } } else { return ‘Album Review: ‘ . $title; }; } add_filter(‘the_title’, ‘append_album_review_to_title’, 10, 2); Explanation First trying this: function append_album_review_to_title( $title, $id … Read more

posts_groupby problem

Your filter will result in SQL query with GROUP BY statement but without aggregate function. This will result in displaying only the first row that appear in the group that match your query and omitting the subsequent rows. Read this question for more details. If you want to order your results by post_type, you can … Read more

Restrict filter to run only inside specific function

wp_terms_checklist early trigger a filter ‘wp_terms_checklist_args’ so you can use that filter to add your filter and auto-remove it haver 1st run. This should be enough, however, once hooks are global variables, to be sure is better use some stronger check, a static variable inside a function is a simple and nice trick: function switch_terms_filter( … Read more

Customize the “Registration complete. Please check your e-mail.” message on WP 4.0

If you need an alternative way, you can always hook into the login_init and modify the gettext filter: add_filter( ‘login_init’, function() { add_filter( ‘gettext’, ‘wpse_161709’, 99, 3 ); } ); function wpse_161709( $translated_text, $untranslated_text, $domain ) { $old = “Registration complete. Please check your e-mail.”; $new = “New text here”; if ( $untranslated_text === $old … Read more

How Can I Have A URL Changed Based on the Originating URL?

You can use the page_link filter with the same logic as the page_template filter in the other answer. If the endpoint query var is set, then any link to a page gets the app-view/ appended: function wpd_page_link( $link, $post_id ){ global $wp_query; if( isset( $wp_query->query_vars[‘app-view’] ) ){ return $link . ‘app-view/’; } return $link; } … Read more

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