Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @twd – exit, exit() and exit(0) are the same. They all means terminate the program successfully.

    Thread Starter TWD

    (@twd)

    thank you.

    Follow up question!

    Why does the first function use:
    wp_redirect( home_url( 'YOUR-TRAILING-SLUG' ), 301 );

    and the second function uses:
    wp_redirect( get_page_link( YOUR-PAGE-ID ), 301 );

    ie. the first uses a page URL and the second uses a page ID.

    If they are interchangeable, which one is considered “best practice” and why?

    Hi @twd – I suggest to use page id because slug might be changed someday but id is unique and permanent.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Why exit() AND exit in these two code snippets?’ is closed to new replies.