Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author TC.K

    (@wp_dummy)

    Random order can be configure at the form setting page.
    The problem is you what to separate the posts that has meta key “recommended” and the posts that have not.
    One way to do this is in the search result while loop, don’t output the html first, instead we put the post object in the placeholder (php array variables) , then we html out put later.

    Thread Starter baga

    (@baga)

    Thansk for replying!
    Could you please paste a sample code?

    Plugin Author TC.K

    (@wp_dummy)

    Here we put the posts objects in the placeholder in the while loop.

    $holder1 = $holder2 = '';//placeholders
    	if ( have_posts() ) {
    		$term = $_GET['taxo'][0]['term'];//get the home taxonomy term slug from the url
    		$termname = get_term_by('slug', $term , 'home'); //get the term object for latter use , eg the term name
    		while ( have_posts() ) {
    			the_post();
    			global $post;
    			$recommend = get_post_meta($post->ID,'recommended',true);
    			if(isset($recommend) || !empty($recommend) ) {                              //if it has recommended meta key
    				$holder1[] = array(
    					'pojb' => $post
    				);
    			}else{
    				   $holder2[] = array(
    					'pojb' => $post
    				);
    
    			}
    
    		} // end while
    	} // end if

    So we can use the placeholders to output the html in the same template:

    <?php
    global $post;
    if(!empty($holder1) || !empty($holder2)){
        //we loop $holder first as it has recommended meta key
        foreach($holder1 as $v){
          $post = $v['pojb'];
          setup_postdata( $post );//use this so that you can access post object like we did in formally while loop
    
          echo '<a href="'.get_permalink.'">'.get_the_title.'</a>';
          //blah blah blah
    
        }
    
        //and loop the $holder2 for the rest of the posts
    
        foreach($holder1 as $v){
             $post = $v['pojb'];
             setup_postdata( $post );
             // 
    
        }
    }else{
        //html for no posts found
    }
    ?>

    Thread Starter baga

    (@baga)

    Thanks for your help but unfortunately I can’t get it to work ??

    Plugin Author TC.K

    (@wp_dummy)

    Well, which part of it you cannot make it work?
    This actually more on PHP, you will need to turn the debug on to see what is the error when you try with the codes.

    Thread Starter baga

    (@baga)

    To begin I don’t understand this part:

    $term = $_GET['taxo'][0]['term'];//get the home taxonomy term slug from the url
    $termname = get_term_by('slug', $term , 'home'); //get the term object for latter use , eg the term name

    What’s the the home taxonomy term slug?

    Plugin Author TC.K

    (@wp_dummy)

    Just a example, it can be any other term or totally ignore it.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Result Page Setting’ is closed to new replies.