WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Defining a home page

[Resolved] Defining a home page

  • tristan.stgermain
    Member

    @tristanstgermain

    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/

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

    @chouby

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

    tristan.stgermain
    Member

    @tristanstgermain

    Hi,

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

    See you.

    Plugin Author Chouby
    Participant

    @chouby

    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

    tristan.stgermain
    Member

    @tristanstgermain

    Hi,

    I still got the same errors 🙁

    Thanks for your help 🙂

    Plugin Author Chouby
    Participant

    @chouby

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

    tristan.stgermain
    Member

    @tristanstgermain

    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(); ?>
    Plugin Author Chouby
    Participant

    @chouby

    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);
    tristan.stgermain
    Member

    @tristanstgermain

    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!

    Plugin Author Chouby
    Participant

    @chouby

    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);

    tristan.stgermain
    Member

    @tristanstgermain

    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

    Plugin Author Chouby
    Participant

    @chouby

    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");

    tristan.stgermain
    Member

    @tristanstgermain

    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!

    Plugin Author Chouby
    Participant

    @chouby

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

    tristan.stgermain
    Member

    @tristanstgermain

    Hi,

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

    See you.

    Plugin Author Chouby
    Participant

    @chouby

    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

Viewing 15 replies - 1 through 15 (of 34 total)
  • The topic ‘[Resolved] Defining a home page’ is closed to new replies.