0

I want when I publish any page, it also set as homepage automatically in my wordpress website.. please help

0

1 Answer 1

2

You want to use update_option for that. https://developer.wordpress.org/reference/functions/update_option/

function set_home_page($post_id) {
    update_option( 'page_on_front', $post_id );
    update_option( 'show_on_front', 'page' );
 }
add_action( 'publish_post', 'set_home_page' );
1
  • Hai, yes same I want to use, but I am not a programmer, so can you provide some code, that I can put. Main main goal is, when I publish any page it automatically set as home page. Thanks in advance bro. Please help
    – Pandit Ji
    Feb 17, 2020 at 3:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.