WordPress.org

Forums

Polylang
[resolved] Polylang and recent post WIDGET-how to force English? (4 posts)

  1. repot
    Member
    Posted 1 year ago #

    Hello
    Please help me to modify Recent post widget to force default language post if translation isn't available. I've got a solution for index.php files etc here. And I'm trying to do the same with my widget code. Please help me to modify the code from widget to show english posts only.

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

  2. repot
    Member
    Posted 1 year ago #

    Code to be modified:

    echo ( $title )? $before_widget . $before_title . $title . $after_title:$before_widget;
    
    		$num_posts_query = new WP_Query( (( $category ) ? "cat=".$category."&": '')."showposts=".$posts_num."&offset=".$offset );
    
    		if( $num_posts_query->have_posts()) {
    		$counter = 0;
    		?>
    		    <div class="wpalp">
    			<ul class="wpalp_thumbnails<?php echo ($thumbnails_only)?' wpalp_thumbonly':''; echo ($thumbnails)?' wpalp_thumbs':'';?>">
    <?php			    while( $num_posts_query->have_posts()) : $num_posts_query->the_post();
    			    update_post_caches($posts);
    				$counter++;
    				?>

    Waiting for a right kind of pilot to come... Please, really need it.

  3. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    Just add the lang parameter in your query:

    $num_posts_query = new WP_Query( (( $category ) ? "cat=".$category."&": '')."showposts=".$posts_num."&offset=".$offset."&lang=en" );
  4. repot
    Member
    Posted 1 year ago #

    Just elegant and awesome! Thank you, Chouby!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Polylang
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic