Skip Navigation

Resolved

Reported for: WPML Multilingual CMS 4.4.8

Resolved in: 4.4.9

Overview of the issue

In some cases, posts and pages that have similar slugs may show the wrong content.

For example, if you have a post type called Books with content at http://example.com/book/title/, and you also have a post with the same slug, http://example.com/title/, you will see the wrong content when visiting these URLs.

Workaround

Our developers are working on fixing the issue.

As a workaround:

  1. Go to plugins/sitepress-multilingual-cms/classes/query-filtering/class-wpml-404-guess.php, line 36
  2. Replace
    	public function guess_cpt_by_name( $name, $query ) {
    		$type  = $query->get( 'post_type' );
    		$ret   = array( $name, $type, false );
    
  3. With
    	public function guess_cpt_by_name( $name, $query ) {
    		$type  = $query->get( 'post_type' );
    		if (empty($type)) {
    		    $type = !empty($query->get( 'pagename' )) ? 'page' : 'post';
    		}
    		$ret   = array( $name, $type, false );
    
    

2 Responses to “Similar slugs can show the wrong post/page on visit”

  1. I am not understanding a thing here! I can’t figure where to go from WPML plugin, this channel isn’t available or I can’t figure it out… plugins/sitepress-multilingual-cms/classes/query-filtering/class-wpml-404-guess.php:L36

    • Hello there,
      The idea is to modify the following file from our core plugin: /sitepress-multilingual-cms/classes/query-filtering//class-wpml-404-guess.php/ line 36.
      If you have any issue finding this file, don’t hesitate to open a ticket in our support forum.

      Regards