add_action uses ‘echo’ add_filter uses ‘return’, why?
add_action uses ‘echo’ add_filter uses ‘return’, why?
add_action uses ‘echo’ add_filter uses ‘return’, why?
If anyone else is having problems with this, it may be due to the Yoast plugin. Use: add_filter( ‘pre_get_document_title’, function( $title ){ // Make any changes here return $title; }, 999, 1 );
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
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
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
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
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
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
You can hook into the ‘add_attachment’ action from wp-includes/post.php Line:3738. It passes in the post_id and from there you can get the file name and then update the post meta with anything you need to.
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