WordPress.org

Ready to get started?Download WordPress

Forums

Search results should show only Dutch or English posts (listings) (15 posts)

  1. matijsnijland
    Member
    Posted 1 year ago #

    Hi everyone,I'm stuck and have some php experience, but this aspect is not working out:

    I am using the custom Smooth Pro theme and the Polylang plugin. Included with the theme is a search widget. The bottom 4 search categories produce post results in English and Dutch. I would like only the language specific post results to be echoed.

    You can see the problem at: http://www.hvhrentals.nl

    The relevant code is:

    <?php
    
    $query = new WP_Query( 'category_name=staff' );
    
    	$args = array(
    	'order'          => 'ASC',
    	'orderby'        => 'menu_order',
    	'post_type'      => 'attachment',
    	'post_parent'    => $post->ID,
    	'post_mime_type' => 'image',
    	'post_status'    => null,
    	'numberposts'    => 1,
    	'lang'           => 'en',
    	);
    
    	$attachments = get_posts($args);
    	if ($attachments) {
    	    foreach ($attachments as $attachment) {
    
    	    echo '<a href='.$surl.'/'.$post->post_name.'>'.wp_get_attachment_image($attachment->ID, 'thumbnail_results').'<span class="'.$fields['statustag'].'"></span></a>';
    	}
    } ?>
    </div>
    <div class="common_right hideOnSearch">
    <span class="results-price"><?php   	include(TEMPLATEPATH."/functions/var/default-box-one.php");
      	include(TEMPLATEPATH."/functions/var/default-box-two.php");
      	include(TEMPLATEPATH."/functions/var/default-box-three.php"); echo $symbols['currency']; echo $fields['price']; ?></span> | <span class="results-meta"><?php echo $fields2['bedrooms']; echo ' '.$options['bedroomstext']; ?></span> - <span class="results-meta"><?php echo $fields2['bathrooms']; echo ' '.$options['bathroomstext']; ?></span> | <span class="results-meta"><?php echo $fields['propertytype']; ?></span><br/>
    
    <div class="excerpt_listing">
    
     <?php
    		$values = get_post_meta($post->ID, 'door', true);
    		 foreach($values as $value) {
    add_filter( 'custom_filter', 'wpautop' );
    echo apply_filters( 'custom_filter', rtrim(substr($value.'…',0,160)).'...<a class="more" href='.$post->post_name.'>more</a>' );
    } ?>
    </div>
    <?php
     echo nmbrpics($post->ID);
    ?>
    </div>
      <div style="clear:both"></div>
    </li>
    <div class="listing_divider hideOnSearch"></div>
    			<?php endforeach; else: ?>
    				<p style="padding:30px;"><?php _e('Sorry, helaas geen resultaten.','belair');?></p>
    			<?php endif; ?>
    
    			<div class="pagination">
    			<?php cps_show_pagination() ?><br/>
    		</div>
    		</div>
    		</ul>
    	</div>
    	<?php
  2. Chouby
    Member
    Posted 1 year ago #

    Polylang knows how to filter the native WordPress search form (GET). But your search is based on a very different search form (POST). You have to find where these POST data are processed and add the language here.

  3. matijsnijland
    Member
    Posted 1 year ago #

    I'm going to check it out, and many thanks, because I'm confident that's the solution. Regards, Matijs

  4. matijsnijland
    Member
    Posted 1 year ago #

    I worked on it all day, but the database is such a puzzle for me. I was trying to select based on language from the database. Help is much appreciated, because I'm stuck:).

    function cps_search_posts(){
    
    		global $CPS_OPTIONS;
    		global $wpdb;
    
    		$join  = '';
    		$where = '';
    		$order = '';
    		$joinedMeta = array();
    		$i = 0;
    		// Custom fields
    		foreach($CPS_OPTIONS['meta_boxes_vars'] as $meta_boxes){
    			foreach($meta_boxes as $metaBox){
    				$mb_name = $metaBox['name'];
    				if(isset($_GET[$mb_name]) && trim($_GET[$mb_name]) != ''){
    
    					$join .= " JOIN $wpdb->postmeta meta$i
    											ON meta$i.post_id = p.ID
    											AND meta$i.meta_key = '_$mb_name' ";
    
    					if($metaBox['type'] === 'range'){
    						$pieces = explode('-',$_GET[$mb_name]);
    						$where .= " AND meta$i.meta_value BETWEEN $pieces[0]+0 AND $pieces[1]+0 ";
    					} else {
    						$where .= " AND meta$i.meta_value = '{$_GET[$mb_name]}' ";
    					}
    
    					$joinedMeta["meta$i"] = $mb_name;
    					// Order:
    
    					if(isset($_GET["order"])){
    						if($_GET["order"] === $mb_name){
    							$asc = isset($_GET["orderdirection"]) ? $_GET["orderdirection"] : 'ASC';
    							$order .= " meta$i.meta_value $asc ";
    						}
    					}
    
    	//				$j = 1;
    	//				while(isset($_GET["order$j"])){
    	//					if($_GET["order$j"] === $mb_name){
    	//						$asc = isset($_GET["orderdirection$j"]) ? $_GET["orderdirection$j"] : 'ASC';
    	//						$order .= " meta$i.meta_value $asc,";
    	//					}
    	//					$j++;
    	//				}
    					$i++;
    				} else {
    					if(isset($_GET["order"])){
    						if($_GET["order"] === $mb_name){
    							$asc = isset($_GET["orderdirection"]) ? $_GET["orderdirection"] : 'ASC';
    							$join .= " LEFT JOIN $wpdb->postmeta meta$i
    													ON meta$i.post_id = p.ID
    													AND meta$i.meta_key = '_$mb_name' ";
    							$order .= " meta$i.meta_value $asc ";
    							$i++;
    						}
    					}
    				}
    
    	//			else {
    	//				$j = 1;
    	//				while(isset($_GET["order$j"])){
    	//					if($_GET["order$j"] === $mb_name){
    	//						$asc = isset($_GET["orderdirection$j"]) ? $_GET["orderdirection$j"] : 'ASC';
    	//						$join .= " JOIN $wpdb->postmeta meta$i
    	//												ON meta$i.post_id = p.ID
    	//												AND meta$i.meta_key = '_$mb_name' ";
    	//						$order .= " meta$i.meta_value $asc,";
    	//						$i++;
    	//					}
    	//					$j++;
    	//				}
    	//			}
    			}
    		}
    			// Custom Taxonomies
    			$is_search_by_tax = false;
    			if( isset($CPS_OPTIONS['taxonomies']) && !empty($CPS_OPTIONS['taxonomies']) ){
    				foreach($CPS_OPTIONS['taxonomies'] as $taxonomy){
    					if(isset($_GET[$taxonomy]) && trim($_GET[$taxonomy] != '')){
    		    $sAlias = preg_replace('#\W#', '_', $_GET[$taxonomy]);
    						$is_search_by_tax = true;
    						$where .= " AND terms_" .$sAlias . ".name = '{$_GET[$taxonomy]}' ";
    
    		    $join .= "
    		     JOIN $wpdb->term_relationships tr_" .$sAlias . " ON tr_" .$sAlias . ".object_id = p.ID
    		     JOIN $wpdb->term_taxonomy tt_" .$sAlias . " ON tr_" .$sAlias . ".term_taxonomy_id = tt_" .$sAlias . ".term_taxonomy_id
    		     JOIN $wpdb->terms terms_" .$sAlias . " ON terms_" .$sAlias . ".term_id = tt_" .$sAlias . ".term_id
    		  ";
    					}
    				}
    			}
    	/*
    			if($is_search_by_tax){
    				$join .= "
    				 JOIN $wpdb->term_relationships tr ON tr.object_id = p.ID
    				 JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
    				 JOIN $wpdb->terms terms ON terms.term_id = tt.term_id
    			";
    			}
    	*/
    			// Pagination:
    			$page_num = isset($_GET['page']) ? (int)$_GET['page'] : 1;
    			$from = $CPS_OPTIONS['per_page']*($page_num-1);
    			$count = $CPS_OPTIONS['per_page'];
    
    			// Order:
    			$order_by = '';
    			if(!empty($order)){
    				$order_by = "ORDER BY ".rtrim($order, ',');
    			}
    
    			$in_posts = implode("','", $CPS_OPTIONS['post_types']);
    
    			 $query = "
                SELECT
                   p.*
                FROM {$wpdb->base_prefix}posts p
                   $join
                WHERE p.post_status = 'publish'
                   -- Only custom posts:
                   AND p.post_type IN ('$in_posts')
                   $where
                   $order_by
                LIMIT $from, $count
             ";
    
    			 global $RES_COUNT;
             global $wpdb;
    
             $RES_COUNT = $wpdb->get_var("
                SELECT
                   count(p.ID)
                FROM {$wpdb->base_prefix}posts p
                   $join
                WHERE p.post_status = 'publish'
                   -- Only custom posts:
                   AND p.post_type IN ('$in_posts')
                   $where
             ");	
    
    			return $wpdb->get_results($query);
    
    	}
    	function cps_ajax_search_results(){
    		echo "<div id='cps_ajax_search_results'></div>";
    	}
    ?>
  5. Chouby
    Member
    Posted 1 year ago #

    O_o

    try this before defining $query:

    global $polylang;
    if (isset($polylang) && class_exists('Polylang_Core') && $polylang instanceof Polylang_Core && isset($polylang->curlang)) {
    	$join .= " INNER JOIN $wpdb->term_relationships AS pll_tr ON pll_tr.object_id = ID";
    	$where .= $wpdb->prepare(" AND pll_tr.term_taxonomy_id = %d", $polylang->curlang->term_taxonomy_id);
    }
  6. matijsnijland
    Member
    Posted 1 year ago #

    Hi Chouby,

    I have included your piece of code, studied it,changed some syntax, because it was not working. The website returns a 500 error. Hope you can help, regards, Matijs

    function cps_search_posts(){
    
    		global $CPS_OPTIONS;
    		global $wpdb;
    
    		$join  = '';
    		$where = '';
    		$order = '';
    		$joinedMeta = array();
    		$i = 0;
    		// Custom fields
    		foreach($CPS_OPTIONS['meta_boxes_vars'] as $meta_boxes){
    			foreach($meta_boxes as $metaBox){
    				$mb_name = $metaBox['name'];
    				if(isset($_GET[$mb_name]) && trim($_GET[$mb_name]) != ''){
    
    					$join .= " JOIN $wpdb->postmeta meta$i
    											ON meta$i.post_id = p.ID
    											AND meta$i.meta_key = '_$mb_name' ";
    
    					if($metaBox['type'] === 'range'){
    						$pieces = explode('-',$_GET[$mb_name]);
    						$where .= " AND meta$i.meta_value BETWEEN $pieces[0]+0 AND $pieces[1]+0 ";
    					} else {
    						$where .= " AND meta$i.meta_value = '{$_GET[$mb_name]}' ";
    					}
    
    					$joinedMeta["meta$i"] = $mb_name;
    					// Order:
    
    					if(isset($_GET["order"])){
    						if($_GET["order"] === $mb_name){
    							$asc = isset($_GET["orderdirection"]) ? $_GET["orderdirection"] : 'ASC';
    							$order .= " meta$i.meta_value $asc ";
    						}
    					}
    
    	//				$j = 1;
    	//				while(isset($_GET["order$j"])){
    	//					if($_GET["order$j"] === $mb_name){
    	//						$asc = isset($_GET["orderdirection$j"]) ? $_GET["orderdirection$j"] : 'ASC';
    	//						$order .= " meta$i.meta_value $asc,";
    	//					}
    	//					$j++;
    	//				}
    					$i++;
    				} else {
    					if(isset($_GET["order"])){
    						if($_GET["order"] === $mb_name){
    							$asc = isset($_GET["orderdirection"]) ? $_GET["orderdirection"] : 'ASC';
    							$join .= " LEFT JOIN $wpdb->postmeta meta$i
    													ON meta$i.post_id = p.ID
    													AND meta$i.meta_key = '_$mb_name' ";
    							$order .= " meta$i.meta_value $asc ";
    							$i++;
    						}
    					}
    				}
    
    	//			else {
    	//				$j = 1;
    	//				while(isset($_GET["order$j"])){
    	//					if($_GET["order$j"] === $mb_name){
    	//						$asc = isset($_GET["orderdirection$j"]) ? $_GET["orderdirection$j"] : 'ASC';
    	//						$join .= " JOIN $wpdb->postmeta meta$i
    	//												ON meta$i.post_id = p.ID
    	//												AND meta$i.meta_key = '_$mb_name' ";
    	//						$order .= " meta$i.meta_value $asc,";
    	//						$i++;
    	//					}
    	//					$j++;
    	//				}
    	//			}
    			}
    		}
    			// Custom Taxonomies
    			$is_search_by_tax = false;
    			if( isset($CPS_OPTIONS['taxonomies']) && !empty($CPS_OPTIONS['taxonomies']) ){
    				foreach($CPS_OPTIONS['taxonomies'] as $taxonomy){
    					if(isset($_GET[$taxonomy]) && trim($_GET[$taxonomy] != '')){
    		    $sAlias = preg_replace('#\W#', '_', $_GET[$taxonomy]);
    						$is_search_by_tax = true;
    						$where .= " AND terms_" .$sAlias . ".name = '{$_GET[$taxonomy]}' ";
    
    		    $join .= "
    		     JOIN $wpdb->term_relationships tr_" .$sAlias . " ON tr_" .$sAlias . ".object_id = p.ID
    		     JOIN $wpdb->term_taxonomy tt_" .$sAlias . " ON tr_" .$sAlias . ".term_taxonomy_id = tt_" .$sAlias . ".term_taxonomy_id
    		     JOIN $wpdb->terms terms_" .$sAlias . " ON terms_" .$sAlias . ".term_id = tt_" .$sAlias . ".term_id
    		  ";
    					}
    				}
    			}
    	/*
    			if($is_search_by_tax){
    				$join .= "
    				 JOIN $wpdb->term_relationships tr ON tr.object_id = p.ID
    				 JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
    				 JOIN $wpdb->terms terms ON terms.term_id = tt.term_id
    			";
    			}
    	*/
    			// Pagination:
    			$page_num = isset($_GET['page']) ? (int)$_GET['page'] : 1;
    			$from = $CPS_OPTIONS['per_page']*($page_num-1);
    			$count = $CPS_OPTIONS['per_page'];
    
    			// Order:
    
    			$order_by = '';
    			if(!empty($order)){
    				$order_by = "ORDER BY ".rtrim($order, ',');
    			}
    
    			$in_posts = implode("','", $CPS_OPTIONS['post_types']);
    
    			global $polylang;
    
    			if (isset($polylang) && class_exists('Polylang_Core') && $polylang instanceof Polylang_Core && isset($polylang->curlang))
    			{
    			$join .= "INNER JOIN $wpdb->term_relationships AS pll_tr ON pll_tr.object_id =";
    			$where .= $wpdb->prepare("AND pll_tr.term_taxonomy_id IN(%s)");
    			$polylang->curlang->term_taxonomy_id);
    			}
    
    			 $query = "
                SELECT
                   p.*
                FROM {$wpdb->base_prefix}posts p
                   $join
                WHERE p.post_status = 'publish'
                   -- Only custom posts:
                   AND p.post_type IN ('$in_posts')
                   $where
                   $order_by
                LIMIT $from, $count
             ";
    
    			 global $RES_COUNT;
             global $wpdb;
    
             $RES_COUNT = $wpdb->get_var("
                SELECT
                   count(p.ID)
                FROM {$wpdb->base_prefix}posts p
                   $join
                WHERE p.post_status = 'publish'
                   -- Only custom posts:
                   AND p.post_type IN ('$in_posts')
                   $where
             ");	
    
    			return $wpdb->get_results($query);
    
    	}
    	function cps_ajax_search_results(){
    		echo "<div id='cps_ajax_search_results'></div>";
    	}
    ?>
  7. Chouby
    Member
    Posted 1 year ago #

    Maybe this:

    global $polylang;
    if (isset($polylang) && class_exists('Polylang_Core') && $polylang instanceof Polylang_Core && isset($polylang->curlang)) {
    	$join .= " INNER JOIN $wpdb->term_relationships AS pll_tr ON pll_tr.object_id = p.ID";
    	$where .= $wpdb->prepare(" AND pll_tr.term_taxonomy_id = %d", $polylang->curlang->term_taxonomy_id);
    }
  8. matijsnijland
    Member
    Posted 1 year ago #

    Hi Chouby,

    There is no 500 error. However, the search module still does not show language specific results. I have a feeling that the if statement is not passed. I hope you have an answer. Thanx for the helps so-far. Best regards, Matijs

    function cps_search_posts(){
    
    		global $CPS_OPTIONS;
    		global $wpdb;
    
    		$join  = '';
    		$where = '';
    		$order = '';
    		$joinedMeta = array();
    		$i = 0;
    		// Custom fields
    		foreach($CPS_OPTIONS['meta_boxes_vars'] as $meta_boxes){
    			foreach($meta_boxes as $metaBox){
    				$mb_name = $metaBox['name'];
    				if(isset($_GET[$mb_name]) && trim($_GET[$mb_name]) != ''){
    
    					$join .= " JOIN $wpdb->postmeta meta$i
    											ON meta$i.post_id = p.ID
    											AND meta$i.meta_key = '_$mb_name' ";
    
    					if($metaBox['type'] === 'range'){
    						$pieces = explode('-',$_GET[$mb_name]);
    						$where .= " AND meta$i.meta_value BETWEEN $pieces[0]+0 AND $pieces[1]+0 ";
    					} else {
    						$where .= " AND meta$i.meta_value = '{$_GET[$mb_name]}' ";
    					}
    
    					$joinedMeta["meta$i"] = $mb_name;
    					// Order:
    
    					if(isset($_GET["order"])){
    						if($_GET["order"] === $mb_name){
    							$asc = isset($_GET["orderdirection"]) ? $_GET["orderdirection"] : 'ASC';
    							$order .= " meta$i.meta_value $asc ";
    						}
    					}
    
    	//				$j = 1;
    	//				while(isset($_GET["order$j"])){
    	//					if($_GET["order$j"] === $mb_name){
    	//						$asc = isset($_GET["orderdirection$j"]) ? $_GET["orderdirection$j"] : 'ASC';
    	//						$order .= " meta$i.meta_value $asc,";
    	//					}
    	//					$j++;
    	//				}
    					$i++;
    				} else {
    					if(isset($_GET["order"])){
    						if($_GET["order"] === $mb_name){
    							$asc = isset($_GET["orderdirection"]) ? $_GET["orderdirection"] : 'ASC';
    							$join .= " LEFT JOIN $wpdb->postmeta meta$i
    													ON meta$i.post_id = p.ID
    													AND meta$i.meta_key = '_$mb_name' ";
    							$order .= " meta$i.meta_value $asc ";
    							$i++;
    						}
    					}
    				}
    
    	//			else {
    	//				$j = 1;
    	//				while(isset($_GET["order$j"])){
    	//					if($_GET["order$j"] === $mb_name){
    	//						$asc = isset($_GET["orderdirection$j"]) ? $_GET["orderdirection$j"] : 'ASC';
    	//						$join .= " JOIN $wpdb->postmeta meta$i
    	//												ON meta$i.post_id = p.ID
    	//												AND meta$i.meta_key = '_$mb_name' ";
    	//						$order .= " meta$i.meta_value $asc,";
    	//						$i++;
    	//					}
    	//					$j++;
    	//				}
    	//			}
    			}
    		}
    			// Custom Taxonomies
    			$is_search_by_tax = false;
    			if( isset($CPS_OPTIONS['taxonomies']) && !empty($CPS_OPTIONS['taxonomies']) ){
    				foreach($CPS_OPTIONS['taxonomies'] as $taxonomy){
    					if(isset($_GET[$taxonomy]) && trim($_GET[$taxonomy] != '')){
    		    $sAlias = preg_replace('#\W#', '_', $_GET[$taxonomy]);
    						$is_search_by_tax = true;
    						$where .= " AND terms_" .$sAlias . ".name = '{$_GET[$taxonomy]}' ";
    
    		    $join .= "
    		     JOIN $wpdb->term_relationships tr_" .$sAlias . " ON tr_" .$sAlias . ".object_id = p.ID
    		     JOIN $wpdb->term_taxonomy tt_" .$sAlias . " ON tr_" .$sAlias . ".term_taxonomy_id = tt_" .$sAlias . ".term_taxonomy_id
    		     JOIN $wpdb->terms terms_" .$sAlias . " ON terms_" .$sAlias . ".term_id = tt_" .$sAlias . ".term_id
    		  ";
    					}
    				}
    			}
    	/*
    			if($is_search_by_tax){
    				$join .= "
    				 JOIN $wpdb->term_relationships tr ON tr.object_id = p.ID
    				 JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
    				 JOIN $wpdb->terms terms ON terms.term_id = tt.term_id
    			";
    			}
    	*/
    			// Pagination:
    			$page_num = isset($_GET['page']) ? (int)$_GET['page'] : 1;
    			$from = $CPS_OPTIONS['per_page']*($page_num-1);
    			$count = $CPS_OPTIONS['per_page'];
    
    			// Order:
    
    			$order_by = '';
    			if(!empty($order)){
    				$order_by = "ORDER BY ".rtrim($order, ',');
    			}
    
    			$in_posts = implode("','", $CPS_OPTIONS['post_types']);
    
    			/*global $polylang;
    
    			if (isset($polylang) && class_exists('Polylang_Core') && $polylang instanceof Polylang_Core && isset($polylang->curlang))
    			{
    			$join .= "INNER JOIN $wpdb->term_relationships AS pll_tr ON pll_tr.object_id =";
    			$where .= $wpdb->prepare("AND pll_tr.term_taxonomy_id IN(%s)");
    			$polylang->curlang->term_taxonomy_id);
    			}*/
    			global $polylang;
    if (isset($polylang) && class_exists('Polylang_Core') && $polylang instanceof Polylang_Core && isset($polylang->curlang))
    {
    $join.= "INNER JOIN $wpdb->term_relationships AS pll_tr ON pll_tr.object_id = p.ID";
    $where.= $wpdb->prepare("AND pll_tr.term_taxonomy_id = %d",$polylang->curlang->term_taxonomy_id);
    }
    
    			 $query = "
                SELECT
                   p.*
                FROM {$wpdb->base_prefix}posts p
                   $join
                WHERE p.post_status = 'publish'
                   -- Only custom posts:
                   AND p.post_type IN ('$in_posts')
                   $where
                   $order_by
                LIMIT $from, $count
             ";
    
    			 global $RES_COUNT;
             global $wpdb;
    
             $RES_COUNT = $wpdb->get_var("
                SELECT
                   count(p.ID)
                FROM {$wpdb->base_prefix}posts p
                   $join
                WHERE p.post_status = 'publish'
                   -- Only custom posts:
                   AND p.post_type IN ('$in_posts')
                   $where
             ");	
    
    			return $wpdb->get_results($query);
    
    	}
    	function cps_ajax_search_results(){
    		echo "<div id='cps_ajax_search_results'></div>";
    	}
    ?>
  9. Chouby
    Member
    Posted 1 year ago #

    yes that's possible if the code above is executed before Polylang sets the current language. With your current Polylang settings, the language is set in a function hooked to 'wp', which is quite late.

    Try with permalinks enabled and the language code in all urls. Thus, the language will be set before the theme.

  10. matijsnijland
    Member
    Posted 1 year ago #

    Hi Chouby,

    I tried with permalinks and enabled language code in the urls. Did not do the trick however. I have another theory and that is that the code refers to non-exhisting tables in the worpress database. I don't know if that's possible. Thanks for the help, thusfar.
    Regards, Matijs

  11. Chouby
    Member
    Posted 1 year ago #

    As you can see, the sql statements I propose uses only the term_relationships table. Can you check if all conditions are passed and if not which ones are false?

  12. matijsnijland
    Member
    Posted 1 year ago #

    Hi Chouby,

    I tested the IF statement by isolating each condition. When isolating isset($polylang), the website returns no posts. Therefore I conclude that somehow there is a problem with the SQL statement. When isolating the other conditions of the IF statement - both the NL and Eng posts are printed, therefore I conclude that these IF conditions are not past and that means, I think, that $join is defined by an earlier statement in the $query.
    Regards, Matijs

  13. matijsnijland
    Member
    Posted 1 year ago #

    Hi Chouby,

    The IF statement is now passed. I added return class_exists('Polylang_Core'), I hope that helps. Now the website does not return any posts. I checked pieces of the code on WP forums and found that p.ID is elsewhere mentioned as ID,somehow the SQL query is not working. Hope you can help? Regards, Matijs

    global $polylang;
    			return class_exists('Polylang_Core');
    if (isset($polylang) && class_exists('Polylang_Core') && $polylang instanceof Polylang_Core && isset($polylang->curlang))
    {
    $join.= "INNER JOIN $wpdb->term_relationships AS pll_tr ON pll_tr.object_id = p.ID";
    $where.= $wpdb->prepare(" AND pll_tr.term_taxonomy_id = %d", $polylang->curlang->term_taxonomy_id);
    }
    
    			 $query = "
                SELECT
                   p.*
                FROM {$wpdb->base_prefix}posts p
                   $join
                WHERE p.post_status = 'publish'
                   -- Only custom posts:
                   AND p.post_type IN ('$in_posts')
                   $where
                   $order_by
                LIMIT $from, $count
             ";
  14. matijsnijland
    Member
    Posted 1 year ago #

    Hi Chouby,

    This issue is resolved. I had a friend take a look at it.
    Thanx for your help.
    Regards, Matijs

  15. Chouby
    Member
    Posted 1 year ago #

    I was out for a while. Glad to read this.

Topic Closed

This topic has been closed to new replies.

About this Topic