Changing the URL slug causes redirecting to homepage, or showing 404 or missing lang_code issue

This is not a solution, but this works some of the times. Try changing each and every relevant settings there is. Since we changed the permalink structure to ‘custom permalink’ the issue has been gone. We were hesitant to change the permalink settings at first because that had caused all our global_colours to ‘invalid’. However, … Read more

Get Page URl when changing slug and permalink

Instead of hardcoding the slug, instead store the ID in an option and then use it to call get_permalink(). You can also avoid hardcoding the $baseUrl and rely on a nav menu or button block instead so that it automatically updates. For example, $page_id = …..; // maybe a `get_option` call or something else? Depends … Read more

What’s the best way to complete links on a certain WordPress Page with everything after the slug?

So, I found a solution that seems to work great and as expected: function custom_username_links_modify_links($content) { global $post; $landing_page_id = get_option(‘custom_username_links_landing_page’); $registration_page_id = get_option(‘custom_username_links_registration_page’); if ($post && $post->ID == $landing_page_id) { $url_path = parse_url($_SERVER[‘REQUEST_URI’], PHP_URL_PATH); $url_parts = explode(“https://wordpress.stackexchange.com/”, trim($url_path, “https://wordpress.stackexchange.com/”)); if (count($url_parts) > 1) { $element = $url_parts[1]; $custom_username = get_user_meta(get_current_user_id(), ‘custom_username’, true); if (!empty($custom_username) … Read more

Using same term for slug and category

OK, found it. it is possible to have the same slug for a page and a category name. The problem was that someone installed a “redirection” plugin that caused the problems. Lesson learned is to restrict the capabilities of people working on the website, so that they cannot install plugins..

Remove Prefix from Custom Post Type Slug

There is a simpler and lighter solution: First: set the slug argument for your custom post type to “https://wordpress.stackexchange.com/” when registering the post type: add_action( ‘init’, ‘register_my_post_type’ ); function register_my_post_type() { $args = array( //The rest of arguments you are currently using goes here ‘rewrite’ => array( ‘slug’ => “https://wordpress.stackexchange.com/” ) ); register_post_type( ‘my-post-type’, $args … Read more

tech