Bug: Post needs to be updated twice when adding action for save_post hook

You’re doing several things wrong, and they’re all silly, avoidable, basic logic mistakes. Firstly, you’re not checking if this is an autosave. Autosaves do not save the custom fields, only the original core wordpress fields, like content, so an autosave will giv eyou unset/blank values. Add this to the top of your save function: if … Read more

publish_post action doesn’t work

It’s never fired since the hook you need is not publish_post but publish_magazine which is actually {$new_status}_{$post_type} hook. So try publish_magazine update: also you don’t need to use get_post since you the hook passes the $post object to the function as a second parameter. take a look at wp_transition_post_status() and if that’s not working then … Read more

Redirect user if they are not logged in

function redirect_user() { if ( $_SERVER[‘HTTP_HOST’].$_SERVER[‘REQUEST_URI’] == ‘www.abc.com/’ ) { if ( ! is_user_logged_in() ) { wp_redirect( ‘http://www.abc.com/de/’ ); exit; } } } add_action( ‘init’, ‘redirect_user’ ); Do you mean something like this?

Call do_action class’s function

No, you can’t. add_action( ‘hook’, array( [class], “method_name” ) ); is the right way to use a method as callback. Read about how to use methods as callback in the codex. If you want to use a static method as callback, do it in this way: add_action( ‘hook’, array( “ClassName”, “method_name” ) );

add_action on a specific page

In your theme’s functions.php file, or the like: add_action( ‘your-custom-action’, ‘wpse8170_media_popup_init’ ); In the page template used for the page in question: do_action( ‘your-custom-action’ );

How to show a users bio on a page

WordPress already comes with the author page/functionality. Let’s say you have the author john on your site www.example.com, then you’d see his author page at www.example.com/author/john. If you want to customize this, you have to tweak (or maybe even create, depending on your theme) the author.php or other author template files.

add_action second argument missing

You have to say how many parameters your callback function needs. The default is 1, so WordPress will pass just $a. To get more parameters, use the fourth argument for add_action(): add_action(‘test’, ‘testing’, 10, 2 );

Add “add to cart” button in WooCommerce [closed]

You’re right about not doing this inside the theme file, also you have the right thing in mind putting this into your functions.php. Try the approach shown below, it’s more you actually need, so pick what’s fitting in your case. Code: //remove add to cart buttons add_action( ‘init’, ‘wpse124288_wc_remove_add_to_cart_buttons’ ); function wpse124288_wc_remove_add_to_cart_buttons() { //add to … Read more