• Resolved dylandawg

    (@dylandawg)


    I have some pages with these permalinks:

    /submit-document/
    /submit-homebrew/

    Now all of a sudden if i go to edit this pages (classic editor) the permalink shows “/submit-4/” and “/submit-3/”

    If i type in manually the words document and homebrew as soon as click “OK” WordPress changes them back to 4 and 3.

    There are no pages in trash, no revisions. No other pages with same name.

    I disabled all plugins and this still happens!
    I never seen anything like it.
    Kinda desperate, what can i do?

    As a last resort i edited these pages slugs directly on the database and so the pages load in their intended permalinks, but on WordPress backend they still show up as “submit-4” and “submit-3” when i hover the “view” link or inside the editor. This is really disturbing for me because those slugs don’t exist on the database at all.

Viewing 2 replies - 1 through 2 (of 2 total)
  • threadi

    (@threadi)

    I would recommend that you do not make any such changes to the database. By doing so, you undermine WordPress’ control of URLs, which can also have a negative impact on accessibility.

    I’m surprised that you first changed the URLs

    /submit-document/
    /submit-homebrew/

    and now they are only called submit-xy. Have you tried changing the URLs back to the above names?

    Two pages with /submit/ as a slug cannot and must not exist. The fact that WordPress appends -3 or -4 here is due to the fact that there are already URLs with -1 and -2. These can be not only pages or posts but also media files or other post types that you use.

    Thread Starter dylandawg

    (@dylandawg)

    I found the problem. I had a filter i forgot about.

    Ideally this filter should only work for custom post types and not the types post and page. But i don’t know how to determine post type on the editor reliably. So I just commented this filter, changed the pages permalink back and uncommented it. Not great. If you know how to not run this for post/page it would be better.

    function remove_false_words($slug) {
    		 
    	  if (!is_admin()) return $slug;
    	  
    	  $keys_false = array('-homebrew', '-document');
    
    	  $slug = str_replace($keys_false,'',$slug);
    	  
    	 return $slug;
    	}
    add_filter('sanitize_title', 'remove_false_words',10, 2);
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Permalink removing words by itself’ is closed to new replies.