Forums Forums Search Search Results for 'found_posts'

Viewing 10 results - 91 through 100 (of 174 total)
  • Author
    Search Results
  • #142093

    Anonymous
    Inactive

    Thanks for that. Wasn’t too sure where to start so I decided using wp_update_post for every post in category 18 (Weekly) would be easier. (Coding is definitely not my strong point!)

    Just for the benefit of anyone else in my situation, I added the following (which I found online somewhere and hacked) to the end of the existing cron job (above) and it seems to have worked…

    $postArgs= array(
        'category' => 18,
        'posts_per_page' => -1
    );
    $postReq= new WP_Query(postArgs);
    if($postReq->found_posts) {
        foreach($postReq->posts as $my_post) {
                $updated_post_info = array(
                    'ID' => $my_post->ID,
                    'pinged' => ''
                );
                wp_update_post($updated_post_info);
        }
    }

    I’ll keep my eye on it to make sure it’s not doing anything else untoward.

    #141442

    Anonymous
    Inactive

    Thanks, Trevor!

    Let me ask one more thing? How can I show a results count in archive page?
    I tried this code:

    $args = array(
     'post_type' => 'my-post-type'
     );
     $the_query = new WP_Query( $args );
     echo 'You found '. $the_query->found_posts . ' posts';

    But it shows ALL posts in that post type, not only the results.

    Any help?

    #136775

    In reply to: Category search


    Trevor
    Participant

    I have a sample results.php for you, but as I can’t test it, I don’t know if it will work:

    <?php
    
    /* Blog Style A */
    
    if ( $query->have_posts() ) {
    	?>
    	
    	Found <?php echo $query->found_posts; ?> Results<br />
    	Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br />
    	
    	<?php
    	while ($query->have_posts()) {
    		$query->the_post();
    
            $cb_post_id = $post->ID;
    ?>
            <article id="post-<?php the_ID(); ?>" <?php post_class('cb-blog-style-a cb-module-e cb-separated clearfix'); ?>>
            
                <div class="cb-mask cb-img-fw" <?php cb_img_bg_color( $cb_post_id ); ?>>
                    <?php cb_thumbnail( '260', '170' ); ?>
                    <?php cb_review_ext_box( $cb_post_id ); ?>
                </div>
    
                <div class="cb-meta clearfix">
    
                    <h2 class="cb-post-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    
                    <?php cb_byline( $cb_post_id ); ?>
    
                    <div class="cb-excerpt"><?php echo cb_clean_excerpt( 160 ); ?></div>
                    
                    <?php cb_post_meta( $cb_post_id ); ?>
    
                </div>
    
            </article>
    
            <?php
    
        }
        cb_page_navi( $cb_qry );
    }
    
    wp_reset_postdata();
    
    ?>
    #135164

    Anonymous
    Inactive

    Thanks for the quick response! I should have mentioned that I’m using the shortcode method for this S&F implementation, so I don’t have an ajax container defined.

    This is the entire results.php template in case that helps:

    <?php
    /**
     * Search & Filter Pro
     *
     * Resource Results Template
     *
     *
     */
    
    if ( $query->have_posts() ) {
    	$total_posts = $query->found_posts;
    	?>
    	<?php
    
    		$current_page = $query->query_vars['paged'];
    		$current_post_count = $query->post_count - 1;
    		$posts_per_page = $query->query_vars['posts_per_page'];
    		$total_posts = $query->found_posts;
    
    		$posts_start = ($current_page - 1 ) * $posts_per_page + 1;
    		if( $posts_per_page > $total_posts ) {
    			$posts_start = 1;
    		}
    		$posts_end = $posts_start + $current_post_count;
    	 ?>
    
    	 <div class="search-filter-results-header">
    		<?php echo $posts_start . "-" . $posts_end . " of " . $total_posts .  __('&nbsp;Resources', 'visceral'); ?>
    	</div>
    	<div class="row resources-list">
    		<?php
    		while ($query->have_posts()) {
    			$query->the_post();
    	
    			get_template_part('templates/list-item-resource');
    		}
    		?>
    	</div>
    	<?php // Pagination
    	$total = $query->max_num_pages;
    	// only bother with pagination if we have more than 1 page
    	if ( $total > 1 ) : ?>
    		<nav class="pagination text-center">
    			<?php
    			// Set up pagination to use later on
    			$big = 999999999; // need an unlikely integer
    			$pagination = paginate_links( array(
    				'base'      => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
    				'format'    => '?paged=%#%',
    				'current'   => max( 1, get_query_var('sf_paged') ),
    				'total'     => $total,
    				'type'      => 'plain',
    				'prev_next' => true,
    				'prev_text' => __('', 'visceral'),
    				'next_text' => __('', 'visceral')
    			) );
    
    			echo $pagination; ?>
    		</nav>
    	<?php endif; ?>
    <?php
    }
    else
    {
    	echo "No Results Found";
    }
    ?>
    

    Thank you!

    #134979

    In reply to: Query issues


    Trevor
    Participant

    Then the count is being made by your theme template file, and must be too early. The count typically looks like this:

    <?php echo $query->found_posts; ?>
    
    #133121

    Trevor
    Participant

    Is this better:

    <?php
    	if ( $query->have_posts() )
    	{
    ?>
    
    		<div style="width: 100%;">Найдено <?php echo $query->found_posts; ?> Результатов<br />
    			<div class="pagination">
    				<div class="nav-previous"><?php next_posts_link( 'Еще результаты', $query->max_num_pages ); ?></div>
    				<div class="nav-next"><?php previous_posts_link( 'Прошлые результаты' ); ?></div>
    			</div>
    		</div>
    	
    		<?php
    		$column_count = 0;
    			while ($query->have_posts())
    			{
    				$query->the_post();
    			?>
    
    				<div class="one_third" style="margin-right: 0px;">									
    					<?php if ( has_post_thumbnail()) { ?>
    					<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
    					<?php the_post_thumbnail(); ?></a><?php } ?>
    				<h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
    				</div>
    
    		<?php
    			$column_count ++; 			
    		}
    	}	
    
    		else {echo "Ничего не найдено";} 
    	?>
    #133001

    Anonymous
    Inactive

    Hi!

    <?php
    	if ( $query->have_posts() )
    	{
    ?>
    
    		<div style="width: 100%;">Найдено <?php echo $query->found_posts; ?> Результатов<br />
    			<div class="pagination">
    				<div class="nav-previous"><?php next_posts_link( 'Еще результаты', $query->max_num_pages ); ?></div>
    				<div class="nav-next"><?php previous_posts_link( 'Прошлые результаты' ); ?></div>
    			</div>
    		</div>
    	
    		<?php
    		$column_count = 0;
    			while ($query->have_posts())
    			{
    				$query->the_post();
    			?>
    
    				<div class="one_third" style="margin-right: 0px;">									
    					<?php if ( has_post_thumbnail()) { ?>
    					<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
    					<?php the_post_thumbnail(); ?></a><?php } ?>
    				<h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
    				</div>
    
    		<?php
    			$column_count ++; 			
    		 ?>
    		}
    	}	
    
    	<?php 
    		else {echo "Ничего не найдено";} 
    	?>

    Parse error: syntax error, unexpected ‘else’ (T_ELSE) in /home/sobaka-pav/dk-moskvor.ru/docs/wp-content/themes/Divi/search-filter/results.php on line 33

    #130732

    Anonymous
    Inactive

    Hi Trevor,

    Here is the full php file for the custom results page.

    <?php
    /**
     * Search & Filter Pro 
     *
     * Sample Results Template
     * 
     * @package   Search_Filter
     * @author    Ross Morsali
     * @link      http://www.designsandcode.com/
     * @copyright 2015 Designs & Code
     * 
     * Note: these templates are not full page templates, rather 
     * just an encaspulation of the your results loop which should
     * be inserted in to other pages by using a shortcode - think 
     * of it as a template part
     * 
     * This template is an absolute base example showing you what
     * you can do, for more customisation see the WordPress docs 
     * and using template tags - 
     * 
     * http://codex.wordpress.org/Template_Tags
     *
     */
    
    if ( $query->have_posts() )
    {
    	?>
    	<div class="resultnumber">
    	Found <?php echo $query->found_posts; ?> Results<br />
    	Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br />
    	</div>
    	<div class="results schoolheadings">
    		<div class="cell heading schoolname">School</div>
    		<div class="cell heading">Full-Time Resident</div>
    		<div class="cell heading">Full-Time Non-Resident</div>
    		<div class="cell heading">Part-Time Resident</div>
    		<div class="cell heading">Part-Time Non-Resident</div>
    		<div class="cell heading"></div>
    	</div>
    	<?php
    	while ($query->have_posts())
    	{
    		$query->the_post();
    		
    		?>
    			<div class="results">
    					<div class="cell schoolname">
    						<h5><span class="showonmobile title">School: </span><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>		
    					</div>
    					<div class="cell"><span class="showonmobile title">Full-Time Resident: $</span>
    				<?php
    					$full_time_resident = get_post_meta(get_the_id(),'full-time_resident_tuition', true);
    					echo $full_time_resident ;
    				?>
    					</div>
    					<div class="cell"><span class="showonmobile title">Full-Time Non-Resident: $</span>
    				<?php
    					$full_time_non_resident = get_post_meta(get_the_id(),'full-time_non-resident_tuition', true);
    					echo $full_time_non_resident;
    				?>
    					</div>
    					<div class="cell"><span class="showonmobile title">Part-Time Resident: $</span>
    				<?php
    					$part_time_resident = get_post_meta(get_the_id(),'part-time_resident_tuition', true);
    					echo $part_time_resident;
    				?>
    					</div>
    					<div class="cell"><span class="showonmobile title">Part-Time Non-Resident: $</span>
    				<?php
    					$part_time_non_resident = get_post_meta(get_the_id(),'part-time_non-resident_tuition', true);
    					echo $part_time_non_resident;
    				?>
    					</div>
    					
    				<div class="cell">
    					<a class="button" href="<?php the_permalink(); ?>">Learn More</a>
    				</div>
    			</div>
    		<?php
    	}
    	?>
    	Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br />
    	
    	<div class="pagination">
    		
    		<div class="nav-previous"><?php next_posts_link( 'Older posts', $query->max_num_pages ); ?></div>
    		<div class="nav-next"><?php previous_posts_link( 'Newer posts' ); ?></div>
    		<?php
    			/* example code for using the wp_pagenavi plugin */
    			if (function_exists('wp_pagenavi'))
    			{
    				echo "<br />";
    				wp_pagenavi( array( 'query' => $query ) );
    			}
    		?>
    	</div>
    	<?php
    }
    else
    {
    	echo "No Results Found";
    }
    ?>

    The code below is also included above and is what pushed data live to the results page

    <div class="cell"><span class="showonmobile title">Full-Time Resident: $</span>
    				<?php
    					$full_time_resident = get_post_meta(get_the_id(),'full-time_resident_tuition', true);
    					echo $full_time_resident ;
    				?>
    					</div>
    #127282

    Anonymous
    Inactive

    Hi I was just wondering if it’s possible to have the post count update dynamically outside of the “Loop”?

    I would like to make a button that say’s: Found <?php echo $query->found_posts; ?> Results<br />. But this does not work outside the page it self.

    Is there away to to this?

    Thanks!

    #126863

    Trevor
    Participant

    This would depend on the Display Results method that you are using. In the plugin folder you will find a folder called templates and in that is the template page that is used by default if you are using the Shortcode Results method. In that you will find this code:

    Found <?php echo $query->found_posts; ?> Results
    

    Your template file would need to have similar code in it (using the correct query name, the one your theme uses). You might find an example in your theme’s search.php template file, if it has one.

Viewing 10 results - 91 through 100 (of 174 total)