Qtranslate Slug
[resolved] A small bug with big influence (5 posts)

  1. Stefan M.
    Posted 2 years ago #

    Do yourself a favor and replace the existing function with that one:

    public function _get_page_link( $link, $id ) {
    		global $post, $wp_rewrite, $q_config;
    		$post2 = $post;
    		if ( !$id )
    			$id = (int) $post->ID;
    			$post2 = &get_post($id);
    		$draft_or_pending = in_array( $post2->post_status, array( 'draft', 'pending', 'auto-draft' ) );
    		$link = $wp_rewrite->get_page_permastruct();
    		if ( !empty($link) && ( isset($post2->post_status) && !$draft_or_pending ) ) {
    			$link = str_replace('%pagename%', $this->get_page_uri($id), $link);
    			$link = trim($link, '/'); // hack
    			$link = home_url("/$link/"); // hack
    			if ($q_config['url_mode'] != 1)
    				$link = user_trailingslashit($link, 'page');
    		} else {
    			$link = home_url("?page_id=$id");
    		return $link;

    Your plugin is then not chaning the $post and a lot of other plugins are working with yours. I only changed the $post to $post2 and many stuff like breadcrumbs, diffrent themes and seo plugins are working again without any problem and also the_title() is returning well what it should and so one ;)


  2. C S
    Posted 2 years ago #

    Stefan, you made my day. Your code fixes a problem that mad me search for 4 days...

    We noticed a strange behaviour in a blog and could absolutely not explain what was happening behind the scenes. I just noticed that –obviously– IDs were mixed up heavily by wordpress.

    To be sure, we added code that would show me the ID not only in the URL but also
    - in the <TITLE>
    - in my page's content (next to the article date, which did not match for the shown headline/text)
    - in a sidebar widget

    In these 4 places, I found 4 different IDs :-/
    I assumed that the fault was in qTranslate itself, but after testing more intensive I could spot "qTranslate-slug" was causing the error.

    And with your code, everything works fine again. Thanks a lot!

    Carlos, you really should update your function :)

  3. Carlos
    Plugin Author

    Posted 2 years ago #

    I take note, thanks!

  4. johnnym26
    Posted 2 years ago #

    You are my hero! Thank you so much! It made my day :-)

    And please, developers of this plugin, prepare 1.2 version with this bug officially fixed.

  5. Carlos
    Plugin Author

    Posted 2 years ago #

    Fixed (https://github.com/not-only-code/qtranslate-slug/issues/31).

    I close this topic.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Qtranslate Slug
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.