WordPress.org

Ready to get started?Download WordPress

Forums

Multilingual Press
[resolved] query_posts() breaks language switcher widget (4 posts)

  1. phil404
    Member
    Posted 1 year ago #

    I'm using WordPress 3.3.2 multisite and Multilingual Press to manage two sites apart from the root: /en/ (English) and /fr/ (French).

    The problem I am having is very specific:

    The language switcher widget no longer works properly when a page template contains any usage of the query_posts() function to fetch posts. Instead of pointing to the equivalent page in the other language, the link on that page will point to the root page of the other language. Removing query_posts() from the template will restore the desired functionality of the language switcher widget.

    Is this a bug with the plugin, or am I missing something?

    Thanks.

    -phil

    http://wordpress.org/extend/plugins/multilingual-press/

  2. phil404
    Member
    Posted 1 year ago #

    Ok, I have found the problem. When using query_posts() replaces the pagename=foo property from the query string, which is required in order to preserve the relationship between the translated pages. Adding pagename=team to my query_posts() query solves the problem of the broken language switcher link, but creates a new problem: no posts are returned from my query. This makes perfect sense, as no posts will contain the property pagename.

    Help. :)

    -phil

  3. Robert Windisch
    Member
    Plugin Author

    Posted 1 year ago #

    Did you do a "wp_reset_query()" after your custom query? The widget is using the current query data, so if you change that you need to reset your changes after your custom loop is done. Other widgets and functions will have that problem too.

  4. phil404
    Member
    Posted 1 year ago #

    Robert,

    If you're ever in Montreal, I would like to buy you a beer or two. I had no idea wp_reset_query() existed.

    Many thanks!

    -phil

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic