how to modify search.php to remove pagination

I've not been able to remove reference to having search results paged. The post page is set up to show one article at a time (they are long) and the search.php seems to apply this set up to search results.

This is part of the code:

<?php

function render_content() {
	$show_paging = true;

?>
	<div class="loop">
		<div class="loop-header">
			<h4 class="loop-title">
				<?php
					$title = sprintf( __( 'Search Results for "<em>%s</em>"', 'it-l10n-Builder-Hudson' ), get_search_query() );

					if ( is_paged() )
						printf( '%s &ndash; Page %d', $title, get_query_var( 'paged' ) );
					else
						echo $title;
				?>
			</h4>
		</div>

		<div class="loop-content">
			<?php if ( have_posts() ) : ?>
				<?php $show_paging = true; ?>
				<?php while ( have_posts() ) : // The Loop ?>
					<?php the_post(); ?>

I've tried to remove reference to "paging", but was not successful. Any ideas how to fix this?
Thanks. The url is (still under development)
http://ethicalinvestor.ca

  • Pixeldrummer

    OK, this is the third try to attach this file. Don't know if you receive responses. The theme I am using is Hudson, iThemes Builder. Am sending you the search.php file which is attached in zip format. I hope you can work with this file. I figured since I've set up to show one post per page, the setting is translated into the search(results) page and shows only one result per page.

    I hope you have enough to work with to change the code and display all results on one page.

  • Pixeldrummer

    It seems that I can't attach a file that is acceptable. Please advise... Meantime am putting the page code in code tags here:

    <?php

    function render_content() {
    $show_paging = false;

    ?>
    <div class="loop">
    <div class="loop-header">
    <h4 class="loop-title">
    <?php
    $title = sprintf( __( 'Search Results for "%s"', 'it-l10n-Builder-Hudson' ), get_search_query() );

    if ( is_paged() )
    printf( '%s – Page %d', $title, get_query_var( 'paged' ) );
    else
    echo $title;
    ?>
    </h4>
    </div>

    <div class="loop-content">
    <?php if ( have_posts() ) : ?>
    <?php $show_paging = true; ?>
    <?php while ( have_posts() ) : // The Loop ?>
    <?php the_post(); ?>

    <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <!-- title, meta, and date info -->
    <div class="entry-header clearfix">
    <h3 class="entry-title">"><?php the_title(); ?></h3>

    <?php // Do not print author, comments, or date information for pages ?>
    <?php if ( 'page' !== $GLOBALS['post']->post_type ) : ?>
    <div class="entry-meta">
    <?php do_action( 'builder_comments_popup_link', '<span class="comments">· ', '</span>', __( 'Comments %s', 'it-l10n-Builder-Hudson' ), __( '(0)', 'it-l10n-Builder-Hudson' ), __( '(1)', 'it-l10n-Builder-Hudson' ), __( '(%)', 'it-l10n-Builder-Hudson' ) ); ?>
    </div>

    <div class="entry-meta date" style="margin-left:72px;">
    <span class="weekday"><?php the_time( 'l' ); ?><span class="weekday-comma">,</span></span>
    <span class="month"><?php the_time( 'F' ); ?></span>
    <span class="day"><?php the_time( 'j' ); ?><span class="day-suffix"><?php the_time( 'S' ); ?></span><span class="day-comma">,</span></span>
    <span class="year"><?php the_time( 'Y' ); ?></span>
    </div>
    <?php endif; ?>
    </div>

    <!-- post content -->
    <div class="entry-content clearfix">
    <?php the_excerpt(); ?>
    </div>

    <?php // Do not print category, tag, or comment information for pages ?>
    <?php if ( 'page' !== $GLOBALS['post']->post_type ) : ?>
    <!-- categories, tags and comments -->
    <div class="entry-footer clearfix">
    <?php do_action( 'builder_comments_popup_link', '<div class="entry-meta alignright"><span class="comments">', '</span></div>', __( 'Comments %s', 'it-l10n-Builder-Hudson' ), __( '(0)', 'it-l10n-Builder-Hudson' ), __( '(1)', 'it-l10n-Builder-Hudson' ), __( '(%)', 'it-l10n-Builder-Hudson' ) ); ?>
    <div class="entry-meta alignleft">
    <div class="categories"><?php printf( __( 'Categories : %s', 'it-l10n-Builder-Hudson' ), get_the_category_list( ', ' ) ); ?></div>
    <?php the_tags( '<div class="tags">' . __( 'Tags : ', 'it-l10n-Builder-Hudson' ), ', ', '</div>' ); ?>
    </div>
    </div>
    <?php endif; ?>
    </div>
    <!-- end .post -->

    <?php comments_template(); // include comments template ?>
    <?php endwhile; // end of one post ?>
    <?php else : // do not delete ?>
    <div class="hentry">
    <div class="entry-content">
    <p><?php _e( 'No results found.', 'it-l10n-Builder-Hudson' ); ?></p>

    <?php get_search_form(); ?>
    </div>
    </div>
    <?php endif; // do not delete ?>
    </div>

    <?php if ( $show_paging ) : ?>
    <div class="loop-footer">
    <!-- Previous/Next page navigation -->
    <div class="loop-utility clearfix">
    <div class="alignleft"><?php previous_posts_link( __( '« Previous Page', 'it-l10n-Builder-Hudson' ) ); ?></div>
    <div class="alignright"><?php next_posts_link( __( 'Next Page »', 'it-l10n-Builder-Hudson' ) ); ?></div>
    </div>
    </div>
    <?php endif; ?>
    </div>
    <?php

    }
    `
    add_action( 'builder_layout_engine_render_content', 'render_content' );

    do_action( 'builder_layout_engine_render', basename( __FILE__ ) );

    ?>

    Is this going to work?

  • Patrick

    Hey there @Pixeldrummer

    I hope you are well today!

    I'd like to help out here, but I'm afraid I don't quite understand the issue at hand.

    Viewing the search results on your site correctly displays a page with excerpts from content corresponding to the search term entered as seen here:
    http://ethicalinvestor.ca/?s=investment

    I also installed the Builder theme one of my test sites and get identical results as seen here:
    http://patrickcohen.net/john-doe/?s=wordpress

    The search results are outputted using the search.php template, not page.php

    Can you provide a link to a search results page on your site where you see the entire content of articles displayed?

  • Pixeldrummer

    Thanks for checking. But the problem is not solved. The number of search results in a results page is exactly dependent on the number of posts you set up to display on the post page (blog). That doesn't make any sense to me, this should be an independent thing.

    I've changed in the WP settings in this site now to display 6 posts on the post page. We are going to convert all long articles to display as teasers. So now when you search, you see up to 6 results, where I would like to see more results displayed on a page. Is there a setting I could put in the search page to display, say, 15 results? And perhaps with shorter teasers?

  • Michael Bissett

    Hey @Pixeldrummer,

    I'm not familiar with the Hudson theme, and I don't have a copy of it to test with at present, but I wanted to ask... have you thought about using something like this?

    https://wordpress.org/plugins/relevanssi/

    With the instructions on this page:

    http://www.relevanssi.com/knowledge-base/posts-per-page/

    You can customize it to show a certain amount of results per page, and you can customize the length of the excerpts in the Settings area for the plugin (it's in the "Custom excerpts/snippets" section).

    Let me know if that helps, or if further work is needed here. :slight_smile:

    Regards,
    Michael

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.