Before I’ve installed polylang, I’ve used following code to display latest topics on my site index page which is outside wordpress.
<?php // Include WordPress define('WP_USE_THEMES', false); require('blog/wp-load.php'); ?> <?php $posts = get_posts('numberposts=4&order=DSC&orderby=post_title'); foreach ($posts as $post) : start_wp(); ?> <h6 class="datum"><?php the_date(); echo "<br />"; ?></h6> <h2 class="naslov"><?php the_title(); ?></h2> <div class="entry-content"><a class="blognaslov" href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">Read More</a><br><br></div> <?php endforeach; ?>
It still works, but displays post in both languages that I use.
Is it possible to display only posts in one of the languages.
I’ve found this in polylang documentation (p.12), but it doesen’t work.
$posts = get_posts(array( 'post_type' => 'post', 'lang' => 'fr', // use language slug in the query 'showposts' => 5 ));
And Second question, is it possible to display links to pages outside wordpress that are added in header.php in language that is currently active?
[ Please do not bump, that’s not permitted here. ]
- The topic ‘Display content in specific language outside wordpress’ is closed to new replies.