WordPress.org

Ready to get started?Download WordPress

Forums

Polylang
[resolved] Defining a home page (35 posts)

  1. tristan.stgermain
    Member
    Posted 1 year ago #

    Hi,

    First thanks for this useful plugin with a lot of configuration, it looks perfect to me (regarding all I've tested before). But I'm facing little problem with home page and pages in general. My default language is French, 2nd is English.

    My home page is a static page witch is loading articles (blog excerpt). So I've defined a new home page in En, new menu in EN and start translate articles but when I'm switching from French to English, the home menu is still loading French articles.
    Also (maybe it's linked) I've got a 404 error on all pages (not on articles).

    Got an idea to help me :)

    Thanks !

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

  2. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    Probably a conflict with your theme. Is it freely downloadable?

  3. tristan.stgermain
    Member
    Posted 1 year ago #

    Hi,

    Thanks for your reply, yes it is:
    http://wordpress.org/extend/themes/responsive

    See you.

  4. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    OK. This theme should work out of the box (This is one I test). There is bug in 1.0 which may cause some of your issues. Could you please install the current development version (1.0.0.2) and tell me is there is still something wrong.
    http://downloads.wordpress.org/plugin/polylang.zip

  5. tristan.stgermain
    Member
    Posted 1 year ago #

    Hi,

    I still got the same errors :(

    Thanks for your help :)

  6. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    Could you explain how you do to load posts from your static page?

  7. tristan.stgermain
    Member
    Posted 1 year ago #

    Hi,

    Under WordPress admin I've set a static page with model "Blog excerpt" model as home page and I've modified the the blog.php file to only load a particular cat ID in home page 'see bellow).

    Do you think problem can be that? Also my theme version is 1.6.8 and last is 1.8.8.

    Thanks !!

    <?php get_header(); ?>
    
            <div id="content-blog" class="grid col-620">
    <?php
        if ( get_query_var('paged') )
    	    $paged = get_query_var('paged');
    	elseif ( get_query_var('page') )
    	    $paged = get_query_var('page');
    	else
    		$paged = 1;
    		<strong>query_posts("cat=1&post_type=post&paged=$paged"); </strong>
    ?> 
    
    <?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
                <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    
                    <h1><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'responsive'), the_title_attribute('echo=0')); ?>"><?php the_title(); ?></a></h1>
    
                    <div class="post-meta">
    
                    </div><!-- end of .post-meta -->
    
                    <div class="post-entry">
                        <?php if ( has_post_thumbnail()) : ?>
                            <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
                        <?php the_post_thumbnail(); ?>
                            </a>
                        <?php endif; ?>
                        <?php the_excerpt(); ?>
                        <?php wp_link_pages(array('before' => '<div class="pagination">' . __('Pages:', 'responsive'), 'after' => '</div>')); ?>
                    </div><!-- end of .post-entry -->
    
                    <div class="post-data">
    				    <?php the_tags(__('Tagged with:', 'responsive') . ' ', ', ', '<br />'); ?>
    					<?php printf(__('', 'responsive'), get_the_category_list(', ')); ?>
                    </div><!-- end of .post-data -->             
    
                <div class="post-edit"><?php edit_post_link(__('Edit', 'responsive')); ?></div>
                </div><!-- end of #post-<?php the_ID(); ?> -->
    
            <?php endwhile; ?> 
    
            <?php if (  $wp_query->max_num_pages > 1 ) : ?>
            <div class="navigation">
    			<div class="previous"><?php next_posts_link( __( '‹ Older posts', 'responsive' ) ); ?></div>
                <div class="next"><?php previous_posts_link( __( 'Newer posts ›', 'responsive' ) ); ?></div>
    		</div><!-- end of .navigation -->
            <?php endif; ?>
    
    	    <?php else : ?>
    
            <h1 class="title-404"><?php _e('404 — Fancy meeting you here!', 'responsive'); ?></h1>
            <p><?php _e('Don't panic, we'll get through this together. Let's explore our options here.', 'responsive'); ?></p>
            <h6><?php _e( 'You can return', 'responsive' ); ?> <a href="<?php echo home_url(); ?>/" title="<?php esc_attr_e( 'Home', 'responsive' ); ?>"><?php _e( '&larr; Home', 'responsive' ); ?></a> <?php _e( 'or search for the page you were looking for', 'responsive' ); ?></h6>
            <?php get_search_form(); ?>
    
    <?php endif; ?>  
    
            </div><!-- end of #content -->
    
    <?php get_sidebar('right'); ?>
    <?php get_footer(); ?>
  8. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    There are 2 issues in your code.

    First you overwrite all query vars except 'paged' in your 'query_post' instruction. So if Polylang has set the query var 'lang', (or if any other plugin set another one) you remove it.
    See http://wordpress.org/support/topic/polylang-homepage-shows-posts-in-both-languages for an example

    And then you query one category for which the language should be defined (French ?), so the result should always be in the language of that category.

    If you want to query a category in multiple languages, then you should first translate the category in your admin and then query something like:

    $args = array('cat' => pll_get_term(1)); // get the translation of category 1 in the current language
    $args = array_merge($GLOBALS['wp_query']->query_vars, $args); // just add our query vars without overwriting the others
    query_posts($args);
  9. tristan.stgermain
    Member
    Posted 1 year ago #

    Hi,

    I'm not too technical but I think I get what you mean.
    So to resume: I translate the category ID 1, then change :

    $paged = 1;
    		query_posts("cat=1&post_type=post&paged=$paged");
    ?>

    to

    $args = array('cat' => pll_get_term(1)); // get the translation of category 1 in the current language
    $args = array_merge($GLOBALS['wp_query']->query_vars, $args); // just add our query vars without overwriting the others
    query_posts($args);

    Is that right?

    Thanks for your time!

  10. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    change all

    if ( get_query_var('paged') )
    	    $paged = get_query_var('paged');
    	elseif ( get_query_var('page') )
    	    $paged = get_query_var('page');
    	else
    		$paged = 1;
    		query_posts("cat=1&post_type=post&paged=$paged");

    to

    $args = array('cat' => pll_get_term(1)); // get the translation of category 1 in the current language
    $args = array_merge($GLOBALS['wp_query']->query_vars, $args); // just add our query vars without overwriting the others
    query_posts($args);
  11. tristan.stgermain
    Member
    Posted 1 year ago #

    Hi,

    Thanks but got this error on home page:

    Fatal error: Call to undefined function pll_get_term() in /homez.83/fredericc/www/wp-content/themes/responsive/blog.php on line 26

  12. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    You should get this error if Polylang is deactivated.

    Well finally I made the test and the code proposed above does not work. I did not test deeply but it's probably a conflict between the cat query var intentionnally added and the page query var not overwritten due to my proposal to do so.

    So let's overwrite query vars as initially done:

    if ( get_query_var('paged') )
    	    $paged = get_query_var('paged');
    	elseif ( get_query_var('page') )
    	    $paged = get_query_var('page');
    	else
    		$paged = 1;
    		$cat = function_exists('pll_get_term') ? pll_get_term(1) : 1; // tests polylang is present before attempting to translate the category
    		query_posts("cat=$cat&post_type=post&paged=$paged");
  13. tristan.stgermain
    Member
    Posted 1 year ago #

    Hi,

    Thanks for that it works for the home page! even if polyland is disabled, you rocks!
    Now just got the problem that the translated pages return me 404 pages? :)

    Thanks again!

  14. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    Have you translated the "uncategorized" category (should be this one with id 1)? Have you posts associated to this translated category?

  15. tristan.stgermain
    Member
    Posted 1 year ago #

    Hi,

    Yes yes, but the problem is only for pages, articles are OK.

    See you.

  16. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    You mean other pages witch use a different template than the one you modified (blog.php) ?

    In that case, could you:
    1. resave your permalinks.
    2. if the problem persists, deactivate all plugins but Polylang and resave your permalinks.
    3. activate your plugins one by one ad check for any conflict with Polylang

  17. tristan.stgermain
    Member
    Posted 1 year ago #

    Hi,

    I've tested with permalinks in Fr + in En saved again it's the same. The same too without any plugin activated except polylang, so it should come from the theme?

    Here is my page.php code just in case ;)

    <?php
    
    // Exit if accessed directly
    if ( !defined('ABSPATH')) exit;
    
    /**
     * Pages Template
     *
     *
     * @file           page.php
     * @package        Responsive
     * @author         Emil Uzelac
     * @copyright      2003 - 2012 ThemeID
     * @license        license.txt
     * @version        Release: 1.0
     * @filesource     wp-content/themes/responsive/page.php
     * @link           http://codex.wordpress.org/Theme_Development#Pages_.28page.php.29
     * @since          available since Release 1.0
     */
    ?>
    <?php get_header(); ?>
    
            <div id="content" class="grid col-620">
    
    <?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
            <?php $options = get_option('responsive_theme_options'); ?>
    		<?php if ($options['breadcrumb'] == 0): ?>
    		<?php echo responsive_breadcrumb_lists(); ?>
            <?php endif; ?>
    
                <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                    <h1><?php the_title(); ?></h1>
    
                    <?php if ( comments_open() ) : ?>
                    <div class="post-meta">
    
                    </div><!-- end of .post-meta -->
                    <?php endif; ?> 
    
                    <div class="post-entry">
                        <?php the_content(__('Read more ›', 'responsive')); ?>
                        <?php wp_link_pages(array('before' => '<div class="pagination">' . __('Pages:', 'responsive'), 'after' => '</div>')); ?>
                    </div><!-- end of .post-entry -->
    
                    <?php if ( comments_open() ) : ?>
                    <div class="post-data">
    				    <?php the_tags(__('Tagged with:', 'responsive') . ' ', ', ', '<br />'); ?>
                        <?php the_category(__('Posted in %s', 'responsive') . ', '); ?>
                    </div><!-- end of .post-data -->
                    <?php endif; ?>             
    
                <div class="post-edit"><?php edit_post_link(__('Edit', 'responsive')); ?></div>
                </div><!-- end of #post-<?php the_ID(); ?> -->
    
                <?php comments_template( '', true ); ?>
    
            <?php endwhile; ?> 
    
            <?php if (  $wp_query->max_num_pages > 1 ) : ?>
            <div class="navigation">
    			<div class="previous"><?php next_posts_link( __( '‹ Older posts', 'responsive' ) ); ?></div>
                <div class="next"><?php previous_posts_link( __( 'Newer posts ›', 'responsive' ) ); ?></div>
    		</div><!-- end of .navigation -->
            <?php endif; ?>
    
    	    <?php else : ?>
    
            <h1 class="title-404"><?php _e('404 — Fancy meeting you here!', 'responsive'); ?></h1>
            <p><?php _e('Don't panic, we'll get through this together. Let's explore our options here.', 'responsive'); ?></p>
            <h6><?php _e( 'You can return', 'responsive' ); ?> <a href="<?php echo home_url(); ?>/" title="<?php esc_attr_e( 'Home', 'responsive' ); ?>"><?php _e( '← Home', 'responsive' ); ?></a> <?php _e( 'or search for the page you were looking for', 'responsive' ); ?></h6>
            <?php get_search_form(); ?>
    
    <?php endif; ?>  
    
            </div><!-- end of #content -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Thanks !!

  18. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    What do you call "permalinks in Fr + in En" ?

  19. tristan.stgermain
    Member
    Posted 1 year ago #

    I mean I'm going in a page edition and change the permalink and save it. That's it?

  20. Ov3rfly
    Member
    Posted 1 year ago #

    "resave your permalinks" means:

    Open this page in admin area: "Settings -> Permalinks" and click "Save Changes"

    http://example.com/wp-admin/options-permalink.php

  21. tristan.stgermain
    Member
    Posted 1 year ago #

    Oh OK, it's done, it result the same error, sorry.

  22. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    What is your permalink setting?
    And what are your Polylang settings?

  23. tristan.stgermain
    Member
    Posted 1 year ago #

  24. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    I still can't reproduce (with WP 3.5.1 + Polylang 1.0.1 + Responsive 1.8.9.3). However I see from your settings that you have other plugins activated. One of these plugins can conflict with Polylang. Could you try to de-activate them all again and after that, click on "Save changes" in "Settings -> Permalinks" (keeping other plugins de-activated).

  25. tristan.stgermain
    Member
    Posted 1 year ago #

    Hum I've tested without any extension activated, got the same so it should only come from the theme I guess.
    I've got version 1.6.8, should I update it?

    Thanks.

  26. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    Yes. You should.

  27. tristan.stgermain
    Member
    Posted 1 year ago #

    I just upadted the theme and the problem stay the same :(

  28. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    That's crazy. I do not understand what could be different in your site from mine. Moreover, I know that other users use this theme without any problem...

  29. tristan.stgermain
    Member
    Posted 1 year ago #

    Hi,

    Yes yes crazy it's a theme witch is used a lot.
    Can I contact someone that can solve my problem directly, I can pay for that of course ;)

    Thanks again for your time.

  30. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    This kind of offer is not allowed on the forum: see http://codex.wordpress.org/Forum_Welcome#Offering_to_Pay

    But I will go on helping you for free :) I want Polylang to be fully compatible with the Responsive theme. You can contact me here.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic