• Resolved Siroj

    (@siroj)


    I’m using polulang and i use a homepage that shows posts from a specific category.

    What do i have to do to get the homepage of the second language to show the posts only from the corresponding category.

    I tried something like this before the loop:

    <?php if (!is_paged() and is_home()) {
    query_posts(‘&cat=4,34’);

    } ?>

    where 4 is the category for the default language and 34 for the second.

    Greetings,
    Joris

    http://wordpress.org/extend/plugins/polylang/

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

    (@chouby)

    Is it a static front page with a specific template ?

    Thread Starter Siroj

    (@siroj)

    Hi Chouby,

    no, it is a frontpage with intro’s from a specific category. I use http://standardtheme.com the standard theme.

    I had to change it a bit for getting the intro to work and to get only intro’s from a specific category.

    Plugin Author Chouby

    (@chouby)

    what was the code before you modified it ?
    In your code, before your category $cat is used, just do this

    $cat = pll_get_term($cat); // does the category translation if necessary

    Thread Starter Siroj

    (@siroj)

    I used different kind of codes.

    The kind i posted above didn’t work, also not with you addition.

    To get only intro-articles from category 4 (dutch homepage-articles) on the homepage i use this code now:

    <?php if ( is_front_page() ) {
          $cat = pll_get_term($cat);
    	  query_posts('&cat=4'); 
    
    } // end if ?>

    That works for the dutch part. But when i click on german it shows the same articles, articles from category 4, then it should show articles from cat 34.

    There wasn’t any code in the template for showing specific articles on the frontpage. Thats why i added the code in the first place.

    I tried a lot od snippets i found using search, but none worked, some showed me all latest posts in German. But i want only to show from a specific category.

    is there a setting or specific way i have to use for the ‘homepage’ in the menu? Hoe does Wordress now its the homepage in another language?

    I use a link to the root of the site as the ‘homepage’….

    So i would think i needed somethink like

    <?php if ( is_front_page() && code for language == nl_NL ){
           $cat = pll_get_term($cat);
    	  query_posts('&cat=4'); 
    
    } // end if ?>

    and the same snippet for german with de_DE and cat=34

    Plugin Author Chouby

    (@chouby)

    Does this work ?
    query_posts('cat='.pll_get_term(4));
    instead of
    query_posts('&cat=4');

    Thread Starter Siroj

    (@siroj)

    🙂 Thanks…

    That did the trick! Really need to dive into php 🙂

    Thread Starter Siroj

    (@siroj)

    Hi,

    the code worked, but i later noticed that the link to older en newer posts didn’t work. They just showed the homepage-posts again.

    So i searched for solutions.

    I found one that worked on the default language homepage. But when i change the language it doesn’t.

    I fiddled around with the code but i lack php-skills…

    Maybe its just something small… I tried something like this.

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=.pll_get_term(4&paged=$paged)");;

    Maybe someone sees an obvious mistake…

    Plugin Author Chouby

    (@chouby)

    Maybe like this ?

    query_posts('cat='.pll_get_term(4).'&paged='.$paged);

    Thread Starter Siroj

    (@siroj)

    Thanks again!

    That works. Newer and older posts now work in the other languages 🙂

    I have a similar problem I think
    I’m using polylang and I use a homepage that shows posts from a specific category too. For this I have the following code in Main Index template:

    <?php if (is_home())
    {
    query_posts(“category_name=’puzzlenews'”);
    }
    ?>
    Currently the homepage shows posts in default language. How do I get the second language (English) homepage to list posts in English?

    Plugin Author Chouby

    (@chouby)

    Could you try to copy / paste http://pastebin.com/utLLn1cu in a php file, upload it in your plugins directory and activate the newly created plugin?

    Unfortunately it triggers an error:

    Plugin could not be activated because it triggered a fatal erro

    r

    Parse error: syntax error, unexpected T_FUNCTION in /home/artistic/public_html/wp-content/plugins/auto translate for Polylang.php on line 18

    Plugin Author Chouby

    (@chouby)

    Ooops. You probably use a php version older than 5.3… I modified the code. Could you try again?

    It generated a warning

    The plugin generated 4 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.

    and later the “headers already sent” error.

    The site uses WordPress 5.3.1

    Here is the link if it helps
    http://puzzlegym.ro/ro/

    Thanks for prompt replies.

    Would you have any other ideas for this problem? Thank you.

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘[Plugin: Polylang] Translations on homepage’ is closed to new replies.