• I have set up the search and it all works except that the search result only shows one and the result is wrong.

    I am using Advanced Custom Fields with this and have no idea how to change the results amount. If I search for all it only give me two pages of results and only with one result per page.

    The page is https://workforce.strikingdesigns.com.au/events-workshops/
    Thanks having lots of trouble getting it to show in the correct order as well.
    This is in the functions:

    
    add_filter('uwpqsf_result_tempt', 'customize_output', '', 4);
    function customize_output($results , $arg, $id, $getdata ){
    	 // The Query
                $apiclass = new uwpqsfprocess();
                 $query = new WP_Query( $arg );
    		ob_start();	$result = '10';
    			// The Loop
    
    		if ( $query->have_posts() ) {
    			while ( $query->have_posts() ) {
    				$query->the_post();global $post;
                                    locate_template( 'events-search.php', TRUE, TRUE );
    			}
                            echo  $apiclass->ajax_pagination($arg['paged'],$query->max_num_pages, 4, $id, $getdata);
    		 } else {
    					 echo  'no post found';
    				}
    				/* Restore original Post Data */
    				wp_reset_postdata();
    
    		$results = ob_get_clean();		
    			return $results;
    }
    

    and this is in the event-search.php

    
     <?php
     $start_date = DateTime::createFromFormat('Ymd', get_field('dates'));
    	$end_date = DateTime::createFromFormat('Ymd', get_field('date_second'));
    	$number = 0.00;
    			   $price = number_format($number, 2, '.', '');
    			   ?>
           <ul class="event-list et_pb_equal_columns">         
            <li>
              <?php $dates = get_field( 'dates' ); ?>
              <?php if ( $dates ) { ?>
              <time datetime="<?php the_field( 'dates' ); ?>"> <span class="dayname"><?php echo $start_date->format('l'); ?></span> <span class="day"><?php echo $start_date->format('d'); ?></span> <span class="month"><?php echo $start_date->format('M'); ?> </span> <span class="year">
                <?php //echo $start_date->format('Y'); ?>
                </span> </time>
              <?php } ?>
              <div class="info"> <span class="category">
                <?php $terms_as_text = get_the_term_list( $post->ID, 'event_type', '', ', ', '' ) ;
    echo strip_tags($terms_as_text); ?>
                </span>
                <h2 class="title">
                  <?php the_title(); ?>
                </h2>
                <?php $presenter = get_field( 'presenter' ); ?>
                <?php if ( $presenter ) { ?>
                <?php } ?>
                <time datetime="<?php the_field( 'dates' ); ?>2"><span class="time"> <i class="fa fa-calendar" aria-hidden="true"></i> <?php echo $start_date->format('l'); ?> <?php echo $start_date->format('d'); ?> <?php echo $start_date->format('M'); ?> <?php echo $start_date->format('Y'); ?>
                  <?php $date_second = get_field( 'date_second' ); ?>
                  <?php if ( $date_second ) { ?>
                  <strong class="hyphen"> - </strong> <?php echo $end_date->format('l'); ?> <?php echo $end_date->format('d'); ?> <?php echo $end_date->format('M'); ?> <?php echo $end_date->format('Y'); ?>
                  <?php } ?>
                  </span> </time>
                <?php $time = get_field( 'time' ); ?>
                <?php if ( $time ) { ?>
                <span class="time"><i class="fa fa-clock-o fa-fw" aria-hidden="true"></i>
                <?php the_field( 'time' ); ?>
                </span>
                <?php } ?>
                <?php $time_second = get_field( 'time_second' ); ?>
                <?php if ( $time_second ) { ?>
                <span class="time"><i class="fa fa-clock-o fa-fw" aria-hidden="true"></i>
                <?php the_field( 'time_second' ); ?>
                </span>
                <?php } ?>
                <span class="time"> <i class="fa fa-map-marker" aria-hidden="true"></i> <?php the_field( 'location' ); ?>
                <?php //$terms_as_text = get_the_term_list( $post->ID, 'event_region', '', ', ', '' ) ;
    //echo strip_tags($terms_as_text); ?>
                <?php //the_field( 'location' ); ?>
                </span>
                <p class="presenter"><strong>Presenter: </strong>
                  <?php the_field( 'presenter' ); ?>
                  <?php $uploaded_pdf_or_file = get_field( 'uploaded_pdf_or_file' ); ?>
    <?php if ( $uploaded_pdf_or_file ) { ?>
    	<a href="<?php echo $uploaded_pdf_or_file['url']; ?>" /><?php echo$uploaded_pdf_or_file['title']; ?></a>
    <?php } ?>
                </p>
                <span class="event-price"><strong>Price: </strong>
                <?php 
    if( get_field('price') == $number  )
    {
        
    	echo "FREE";
    }
    else
    {
         echo '$' . get_field('price') . '';
    }
    ?>
                </span> <a href="<?php the_field( 'payment_url' ); ?>" target="_blank" class="product-buttons">REGISTER</a> </div>
            </li>
            </ul>
    

    Thanks

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter nanny7

    (@nanny7)

    Am I meant to put in the code I would usually put in for the page e.g.

    
    $today = date('Ymd');
    $args = array(
    'post_type' => 'events',
    'post_status' => 'publish',
    'posts_per_page' => '-1',
    'meta_query' => array(
            array(
                'key' => 'dates',
                'compare' => '>=', // Upcoming Events - Greater than or equal to today
                'value' => $today,
            )
        ),
        'meta_key' => 'dates',
        'orderby' => 'meta_value_num',
        'order' => 'ASC',
        );
    
    	
    			  $my_query = new WP_Query( $args );
    			  if ( $my_query->have_posts() ) {
    
     
         
            while ( $my_query->have_posts() ) : $my_query->the_post();  ?>
    
    Plugin Author TC.K

    (@wp_dummy)

    Look at the Result Page Setting section, you can configure Results per Page: there.

    If you want it to shows all the results in one page. Before the inject arguments $arg to wp_query class in the result customization filter:

    	 // The Query
                $apiclass = new uwpqsfprocess();
    
                 $arg['posts_per_page'] = '-1';
                 $query = new WP_Query( $arg );
    Thread Starter nanny7

    (@nanny7)

    Thanks I won’t use that -1 because I want to paginate but how to add my compare

    
    $today = date('Ymd');
    'meta_query' => array(
            array(
                'key' => 'dates',
                'compare' => '>=', // Upcoming Events - Greater than or equal to today
                'value' => $today,
            )
        ),
        'meta_key' => 'dates',
        'orderby' => 'meta_value_num',
        'order' => 'ASC',
        );
    

    thanks

    Thread Starter nanny7

    (@nanny7)

    Also on another page I will need to use a custom field “featured” item to add to the sort order as well as the custom field “dates” how do I do this, thanks.

    Thread Starter nanny7

    (@nanny7)

    Hi I just added:

    
     $arg['posts_per_page'] = '3';
    

    and it still shows only one per page and the result is wrong if I search event_type and there are 3 to show it only shows 2 and one is a past date not one in the future like it should show in my compare.

    Plugin Author TC.K

    (@wp_dummy)

    You can set it in the form setting page for result per page. Don’t use the $arg['posts_per_page'] = '3';

    If it’s doesn’t works, you can print out the query and arguments.

    eg:

    print_r($arg);
    $query = new WP_Query( $arg );
    print_r($query);
    Thread Starter nanny7

    (@nanny7)

    Hi I still only get one result ever and the results are wrong in the count of being shown.

    Thread Starter nanny7

    (@nanny7)

    Can you please let me know why I am only getting one result please.
    Thanks

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘only one result and result is wrong’ is closed to new replies.