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

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

How to find what is causing a slug-2?

Step 1: Get all the available post types. This is done with the following query global $wpdb; $query = “SELECT DISTINCT post_type FROM {$wpdb->posts}”; $results = $wpdb->get_results($query); foreach ($results as $result) { echo “‘” . $result->post_type . “‘,”; } Step 2: Use WP_Query to find the instance with the original slug: $slug = ‘support’; $args … Read more

WP appending -2 to the end of my slug

It might not be a Page. WordPress is very picky about slugs sometimes. You might have to dig in the database’s wp_posts table and see what other post exists somewhere with that name – sometimes it can be an odd thing like a Media Library (image) file. Once you find it, if you completely delete … Read more

Duplicate Slugs on multilingual site (with Polylang)

Go on your back-office, and go on Polylang (Languages) Settings. Then, on URL modifications, check if the option “The language is set from the directory name in pretty permalinks” is checked. If not, check it. Then click on Save changes. Now, you should see this option below : “Share slugs Activated” “Allows to share the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)