• Hey everyone,

    I am making a website based on Aggregate from ElegantThemes. This is the temporary website url: https://s352181139.domenaklienta.pl/wordpress/

    Everything goes easy but there are a few things that are quite confusing for me. I am not so advanced to discover what is going on by my own.

    Carousel
    First of all, the theme allows me to create a carousel (you can see it on the website). The problem is that even I change the language the carousel shows english content. Is there any way to change it? Maybe there is a problem with categories?

    “Recent from…”
    The same thing is with the “Recent from…” section. It still shows the english content.

    Those are two major problems with making the translation. Could anyone help me? I would be grateful.

    With best regards,
    Prince Raven. ??

    https://www.ads-software.com/extend/plugins/polylang/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Chouby

    (@chouby)

    Could you try with the development version ? A bug which prevents the language filter to work in some cases (when the query includes an array of post types) was introduced in V0.8.

    If it does not solve the issue, could you post the query used to retrieve the posts included in the carrousel or the “recent from…” ?

    Thread Starter princeraven

    (@princeraven)

    query_posts(array
    ('post_type' => 'page',
    'orderby' => 'menu_order',
    'order' => 'ASC',
    'post__in' => (array) get_option('aggregate_feat_pages'),
    'showposts' => (int) $featured_num));

    As far as I understand this query is used to this operation. ??

    That seems to be a query for pages rather than posts, although it’s hard to tell from URL or body class if opened entity is page or post.

    The query you posted gets an option to determine which categories to include, so you should intercept the option call with option_aggregate_feat_pages filter and use Polylang function pll_get_term to get translated categories and return those instead.

    Plugin Author Chouby

    (@chouby)

    I made a test with the query above (on the front page and without the get_option as I don’t have the theme) and it displays correctly pages *filtered by language*.

    So the query does not seem to be the source of the problem. Did you find it in home.php file ?

    Did the English pages displayed already exist before you installed Polylang? If yes do you see an option displayed in red in the Polylang settings ?

    Thread Starter princeraven

    (@princeraven)

    Hello,
    I found these lines in includes/featured.php (which I suppose is responsible for the carousel).

    Maybe one of you would give me his e-mail address so I could send you the theme. I could repay in a way.

    Thank you in advance,
    Prince Raven.

    No need to send proprietary non-free theme to someone. That would violate copyrights of theme authors.
    You can use https://pastebin.com/, create new paste of includes/featured.php and post the link here.

    It is strange that query_posts() is used for separate loop, because it modifies main $wp_query instance. It’s better to use get_posts() or new WP_Query object unless you want to replace main query.

    Thread Starter princeraven

    (@princeraven)

    Bonjour ??

    That’s the link to the source: https://pastebin.com/pHRKRLCP

    You are so kind, thank you ??

    With peace,
    PR.

    Witam, panie Princeraven! ??

    IMHO the theme is doing it wrong. query_posts() resets main query and ignores Polylang language filters. get_posts() should be used for secondary loops instead of query_posts(). Please tell it to the theme developers and send them link to codex page about query_posts.

    Easiest way to fix it and make the query include the language filter would be to add 'lang' => get_query_var('lang'), to query args array.
    I made a new version with few corrections of your paste: https://pastebin.com/2V833t1k
    Didn’t test, but it should fix the problem for now.

    Plugin Author Chouby

    (@chouby)

    I agree with you get_posts would be better than query_posts. I guess the author is using it because he finds convenient to have a second loop. However he correctly uses wp_reset_query after his secondary loop. And that’s why the main loop is not broken.

    The quick fix proposed is probably OK but I still do not understand why it is not working out of the box…

    The comment for query_posts() in wp-includes/qurey.php says it all:

    This will override the current WordPress Loop and shouldn’t be used more than
    once
    . This must not be used within the WordPress Loop.

    Main query is reset with this:

    unset($GLOBALS['wp_query']);

    which also deletes all query_vars including lang. The query() method replace query and query_vars by given arguments and ignores all filters.
    I used query_posts() on pages to display posts from a category instead of page content and it messed up language switcher by adding category slug in links.

    Another problem in this theme is get_cat_ID($featured_cat) which ignores language filter and always returns category id depending on slug.
    This could be solved in Polylang by adding get_category filter which is applied in get_term_by() function. The filter function should return taxonomy in current language. That could potentially create a loop in other parts of Polylang where taxonomies are queried.

    I’m looking at Polylang_Base::get_term() and it is really hard to read the way it is written now. And IMO the function, judging by name, should return a term object instead of term_id.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Plugin: Polylang] Translation with Aggregate (from Elegantthemes)’ is closed to new replies.