Combine two different filter callback functions

I think you could or even should combine your filters to keep your code DRY. add_filter(‘script_loader_tag’, function( $tag, $handle ) { if ( ‘chargebee’ == $handle ) : return str_replace( ‘ src’, ‘ data-cb-site=”mydomain” src’, $tag ); elseif( ‘google-maps’ == $handle ) : return str_replace( ‘ src’, ‘ async=”async” defer src’, $tag ); endif; return … Read more

Add function to every post?

One way to do that is to have the custom dropdown function return the custom html. Then you can call it inside your add_dropdown_to_posts and put the returned content into a helper variable. After that just prepend the custom html to the $content variable that the the_content filter provides. Like this, function my_custom_dropdown_html() { return … Read more

Last updated date function

You can check for your “home page” at the start of your function by using is_home() and/or is_front_page() and just return original content without date. See is_home vs is_front_page function wpb_last_updated_date( $content ) { if ( is_home() || is_front_page() ) return $content; //homepage return content without date // your original function code } Alterantively you … Read more

Inserting a functions output after the content

Your shares_content function directly outputs content, which won’t work if you’re trying to assign the results to a variable or use it in a return statement within another function. You can change it to return the string: function shares_content() { $content = “<div class=”social-shares-container”><a href=”https://www.facebook.com/sharer/sharer.php?u=%s”>Share on Facebook</a></div>”; return sprintf( $content, get_permalink() ); } It’s also … Read more

Php function 301 redirect

There is nothing wrong with wp_redirect part of your code… But… is_page function can’t be used with URL address… You should pass “Page ID, title, slug, or array of such” as stated in documentation.

WordPress upload_mimes not working for front-end uploads of 3D files

Thanks to this thread here, I found this code function fix_wp_csv_mime_bug( $data, $file, $filename, $mimes ) { $wp_filetype = wp_check_filetype( $filename, $mimes ); $ext = $wp_filetype[‘ext’]; $type = $wp_filetype[‘type’]; $proper_filename = $data[‘proper_filename’]; return compact( ‘ext’, ‘type’, ‘proper_filename’ ); } add_filter( ‘wp_check_filetype_and_ext’, ‘fix_wp_csv_mime_bug’, 10, 4 ); which does allow the files to be uploaded through the … Read more

Add Featured image column into wordpress admin on pages AND posts

The reason you’re getting an error is because you’ve got multiple functions with the same name. You have two functions called add_img_column() and two called manage_img_column(). You can’t have two functions with the same name in PHP. You don’t even need two functions though. You can hook the same function into multiple hooks. So this … Read more