Is it possible to show the WordPress home page slug visible in the URL bar? I mean when someone visits my WordPress website home page rather than displaying (considering that my website URL is website.com) "website.com" it must shows "website.com/home-slug" in the browser URL bar. Note: I am using a static page as the home page and my permalink uses "post-name". I am not looking for a way to hide the home slug but a way to make it visible …
I need to search for wordpress posts with input slug or old slug only 1 parameter in single API. Now I'm using 2 url: 1. /wp-json/wp/v2/posts?slug=hello-world 2. /wp-json/wp/v2/posts?meta_key=_wp_old_slug&meta_value=hello-world How can I solve this problem? Wordpress version: 5.9
Am trying to add custom path to my article posttype so my article path will be www.example/parent-post-1/parent-post-2/the-actual-post i tried to add this code /** * @param $post_link * @param $id * Добавить название категории продукта к ссылке * @return array|mixed|string|string[] */ function wpa_course_post_link($post_link, $id = 0) { $post = get_post($id); if ($post instanceof WP_Post) { $parent = get_field('parents', $post->ID) ?: []; $link = ''; foreach ($parent as $post) { $link .= $post->post_name . '/'; } if ($parent) { $post_link = …
I have a custom post type called "equipment". I would like the permalink structure to be: example.com/equipment/%post_id%-slug I specifically want it to use a dash and not a slash (i.e. - "id-slug" not "id/slug"). Every possible solution I've found from googling has used slashes and I just can't get it to work with a dash. I also want to prevent WordPress from adding on the additional number if there's two posts with the same title. Example: example.com/equipment/45-awesomeness and example.com/equipment/46-awesomeness-2 I …
I am trying to strip the following characters out of slugs: ṁ, ṭ, ḍ, ṇ, ṅ, ñ, ḷ, ṃ. I found this code here (note: I have removed public in order to get it to work) add_action('wp_insert_post_data', __NAMESPACE__ . 'processPermalink'); /** * Processes the permalink so we can remove any characters that may cause a problem when communicating * with the API. * * @param array $data The array of information about the post. * @return array $data The data …
I am having trouble changing the slug of my archive page. The goal is to create a page that can be edited from the back end of WP with the slug speakers, but that has already been taken by the archive page. This has to be client friendly so it can't be only editable in the php. I am willing to do whatever anyone thinks is the best idea for this. Ideas: removing the archive page all together rewriting the …
I want to add an option to my site to filter posts by one specific tag on the category page and at the same time have a nice URL (no query strings). So something like this: https://example.com/%category%/ - standard category link (currently) https://example.com/%category%/%tag%/ - a page like the above, but displaying posts from a specific category AND tag. Is this possible? If so, how can I achieve this? I would also like to note that for posts I have such …
I am trying to configure WordPress 5.9 to allow numeric slugs for child pages. Drawing from the 2015 answer to a similar question I took the up-to-date code of wp_unique_post_slug, removed || preg_match( "@^($wp_rewrite->pagination_base)?\d+$@", $slug ) and then added it as the following hook to my theme's functions.php. But for some reason, I just get a critical error: "Allowed memory size exhausted". What can I do to allow numeric slugs for child pages? add_filter( 'wp_unique_post_slug', function ( $slug, $post_ID, $post_status, …
Can I assign WP php file (specific template) to several pages with same prefix name/slug using (if is_page(){}) ? If it's possible it could be useful. Is there a php function to do like css selector : [class*="activity-"] for example ??: if(is_page('[activity-]')){ include "activity.php"; } the goal is to not repeat 4 times the same function : if(is_page('activity-sport')){ include "activity.php"; } activity.php assign to : website/activity-sport website/activity-culture website/activity-charity website/activity-work
I have a form that visitors use to upload files and fill out information about them and a function that adds those files to the media library and set various fields (including some custom taxonomies) on the media library items based on fields that the visitor filled out in the form. The problem is, I have an email address field. When a visitor fills out the email address field with "[email protected]", what is displayed on the Attachment details screen (as …
I have a custom field with ACF named "short_title" and I want the post's slug based on this field instead of the post title field. I already wrote this code: function testSlug($post_id) { if (get_post_type($post_id) == 'my-custom-post-type') { if (defined('DOING_AUTOSAVE' && DOING_AUTOSAVE)) { return; } if (!current_user_can('edit_post', $post_id)) { return; } remove_action('save_post', 'testSlug'); $updated_post = []; $updated_post['ID'] = $post_id; $updated_post['post_name'] = sanitize_title($_POST['acf']['field_61f8bacf53dc5']); wp_update_post($updated_post); add_action('save_post', 'testSlug'); clean_post_cache($post_id); } } add_action('save_post', 'testSlug'); this works great and edit the slug, but on the …
I'm trying to edit the slug field on the right panel of Gutenberg editor and edit its content based on a custom field. I noticed that I can access to the field by using wp.data.select('core/editor').getEditedPostSlug(); in JavaScript to interact with the React Component. My question is: how can I edit this field in JavaScript? There's no .setEditedPostSlug() method for this and select the field in normal JS script is impossible because the field's ID is generated each time the panel …
I have a theme with hardcoded permalink structure for some posts. Those posts open with site.com/parent/page structure. I created a filter that replaces the link from "site.com/parent/page" to "site.com/newparent/page" in functions.php with: add_action('init', 'change_slug_of_post_type_parent', 20); function change_slug_of_post_type_parent() { $args = get_post_type_object("parent"); $args->rewrite["slug"] = "newparent"; register_post_type($args->name, $args); } Links are now generated OK, but when I click on them, the page doesn't load. Can someone please help? I am sure this is easy fix, but I cant get around it. I …
I have these two issues: 1: WARNING: Your theme appears to be in the wrong directory for the theme name. The directory name must match the slug of the theme. 2: REQUIRED: The <title> tags can only contain a call to wp_title(). Use the wp_title filter to modify the output For #1 Based on what I searched, the text domain is the theme name both of the folder and in style.css. I have checked and they all are the same. …
I am using wordpress and all I want to do is make the URL appear in the form where, Blogs is mentioned and then the blogname. But I want this structure only when someone visits blogs page. The blogs slug shouldn't appear elsewhere like if i go another page, then the blogs shouldn't be shown. The structure I am desiring should only appear when someone is accessing blogs pages. For Ex: www.example.com/blogs/blogname - That's it! NO CATEGORY, NO NOTHING. ONLY …
I took over a website that was developed by someone else and have rebuilt it to function in Elementor. Everything works great, except for one Archive page with the slug “our-projects” that I can’t seem to edit or access (it is not an existing page and the Trash has been emptied). The problem is I have another Projects page I need to assign the “our-projects” slug to as this slug has a long SEO history. As this Archives Page exists, …
domain.tld/post-name | post_id = 5 and domain.tld/post-name-2 | post_id = 77 The above scenario is the solution brought by wordPress. Let's complicate this a bit and add it as a prefix for example or timestamp etc. If we want to add something, how do we do it?
Please How do I achieve this? I have WordPress Default Taxonomy - Tag and a custom Taxonomy - Artist. I want to check for TAGS that have the same slug as ARTIST and 301 redirect it to the ARTIST. Example Check If: website.com/tag/drake and website.com/artist/drake have the same slug which is true. then Automatically 301 Redirect: website.com/tag/drake to website.com/artist/drake If the slug is not the same, then do nothing. I found this Answer but it's not exactly what I need …
important try as normal contributor user, not as admin see here I actually have it reproduced. Seems like a bug to me but whatever. I want users to choose their slug. Well, as you cannot store post_name in pending posts, where should I store it? where does wordpress store the slug the user chooses while it is still draft / pending? EDIT my code, this works as it is publish status: $post_information = array( 'post_title' => 'Your title', 'post_content' => …
Recently I Found some error on WordPress sites that when someone enter a question mark after the root domain and type any word, url shows the Home Page of instance: For instance, Root Domain is abc.com abc.com/?anyword should be reached on the 404 not found page which shows the home page. I need help with this Issue: https://www.iadm.edu.pk/?anyword should be redirected to the 404 not found page.