Unique one time use URL

You could add a setting using add_option( ‘access_keys’, [ ‘key_1’, ‘key_2 ] ) to check against when loading the page. add_action( ‘init’, ‘wpse339612_check_access_codes’ ); function wpse339612_check_access_codes(){ if( isset( $_GET[‘key’] ) ){ $available_keys = get_option( ‘access_keys’ ); $key_index = array_search( filter_var( $_GET[‘key’], $available_keys ); if( $key_index !== false ){ /*User has access! Delete the key from … Read more

Redirect non existing page to frontpage

You can use conditional tag is_404() and wp action hook to redirect whenever the page can not be found. functions.php add_action( ‘wp’, ‘se344018_redirect_404’ ); function se344018_redirect_404() { if ( is_404() ) { wp_redirect( home_url() ); // // wp_redirect( home_url(‘some/page-slug’) ); exit; } }

HTTP 403 Error when passing parameters to URL

I can guarantee that somewhere on your technology stack (edge CDN, Firewall, Web Server, WordPress Plugin) that you have something configured that throws a 403 error whenever you try to access a URL on your site without the User-Agent Header set. Hence why it works when you access in the browser (as this will contain … Read more

Can anybody provide me with a function to generate slugs?

This post provides a function, but it cannot handle non-latin characters. That’s because URLs can’t have non-latin/ASCII characters. Browsers might show non-latin characters to you, but it’s just a user interface feature. For example, if you visit this Wiktionary URL: https://en.wiktionary.org/wiki/わかもの#Japanese, you browser URL encodes the japanese characters to get the real URL: https://en.wiktionary.org/wiki/%E3%82%8F%E3%81%8B%E3%82%82%E3%81%AE#Japanese then … Read more

How to check if the current page is at a specified path in the URL?

You could try this instead if (!is_front_page() && is_home()) { get_template_part(‘template-parts/blog-categories’); } Explanation for the difference between front_page an home is here: https://wordpress.stackexchange.com/a/239838 if you set a page as a blog-page it is “home”, in your case the landing-page is the so called “front_page”. This is WordPress specific.

Will get_bloginfo(‘url’) return URL with backslash?

The Codex example for home_url() says you want home_url( “https://wordpress.stackexchange.com/” ) to get the blog’s URL with a trailing slash. Alternatively you could use trailingslashit( home_url() ). That may be safer if your site’s home option somehow ends up stored with a trailing slash, since it looks like get_home_url() assumes it isn’t, but that ought … Read more

How do you make homepage redirect to it’s slashed version?

What you are asking for is impossible, and if SEO consultants are asking for this then they do not know what they’re talking about. WordPress is not redirecting you to a non-slashed homepage, the change happens before your browser even starts the request. To understand why, take a look at one of the most basic … Read more