Thread Starter
Zurd
(@zurd)
This is the code that loops in my search.php file that prints every page title. If there was only a way to test what language is for the_post()
<?php while (have_posts()) : the_post(); ?>
<div <?php post_class() ?>>
<h3 id=”post-<?php the_ID(); ?>”>
” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title(); ?>
</h3>
</div>
<?php endwhile; ?>
Thread Starter
Zurd
(@zurd)
Solved, here’s the code I used, it’s the search form :
<?php
$currentlang = get_bloginfo('language');
if ( $currentlang=="en-CA" ) {
echo "<h2>Search</h2>";
echo '<form method="get" id="searchform" action="' . site_url() . '/en/">';
}
else {
echo "<h2>Recherche</h2>";
echo '<form method="get" id="searchform" action="' . site_url() .'/fr/">';
}
?>
<input type="text" value="<?php echo wp_specialchars($s, 1); ?>" name="s" id="s" size="15" />
<input type="submit" value=">" />
</form>
Plugin Author
Chouby
(@chouby)
Yes, or you could have used:
echo "<h2>" . __('Search', 'your_theme_textdomain') . "</h2>";
echo '<form method="get" id="searchform" action="' . home_url() . '">';
as Polylang automatically modifies the home url according to the language and does not modify the site url as it is not language dependant.
At first line, I used the translation function of WordPress using po/mo files
Thread Starter
Zurd
(@zurd)
Using the home_url instead of site_url just takes me back to my homepage without any search results.
Using the translation po/mo files of wordpress is better than what I do but what I did is already working and I don’t have no po or mo files to compile, yes, I’m lazy.
Thanks for providing us polylang, this is the best translation plugin I ever used, if I ever finish the 2 websites that is using it, I’ll donate, thanks again.