Redirect User when they click Menu Option

The first problem I see is here: if( get_page_by_slug($slug) ){ }wp_redirect(‘https://example.com/private-page/’.$slug.”https://wordpress.stackexchange.com/”); exit; The if() statement will do nothing; your wp_redirect() and exit statements are outside the {} braces. Try this instead: if( get_page_by_slug($slug) ){ wp_redirect(‘https://example.com/private-page/’.$slug.”https://wordpress.stackexchange.com/”); exit; } Aside from that, a couple other things to check: You say the code is in function.php; if you’re … Read more

how to add functions to my function.php using a child theme?

The site crashes, because you have a typo in that code. You’re missing an apostrophe at the beginning of the string: // Custom Function to Include function my_favicon_link() { echo <link rel=”shortcut icon” type=”image/x-icon” href=”https://wordpress.stackexchange.com/favicon.ico” />’ . “\n”; ^ missing apostrophe } add_action( ‘wp_head’, ‘my_favicon_link’ ); Here’s the fixed version: // Custom Function to Include … Read more