Combining search results

To produce a combined display of the normal WP search results and the WPPA+ serach results do the following:

  1. Find the file search.php in your theme directory, and bring it in a text editor.
  2. Locate the line where the decision is made if there is anything to show on the page:
    <?php if ( have_posts() ) : ?>
    and change it into the next 3 lines that will find out if there are posts or photos to be printed:

    <?php $have_photos = function_exists('wppa_have_photos') && wppa_have_photos('450'); ?>
    <?php $have_posts  = have_posts(); ?>
    <?php if ( $have_posts || $have_photos ) : ?>
  3. The next action is to find the place where the posts are printed. There are two possibilties:
    • <?php while ( have_posts() ) { : ?>
      change it into:
      <?php if ( $have_posts ) while ( have_posts() ) { : ?>
    • get_template_part( 'loop', 'search' );
      change it into:
      if ( $have_posts ) get_template_part( 'loop', 'search' );
  4. Add after the the closing of the while loop:
    if ( $have_photos ) wppa_the_photos();
    (make sure this code is within <?php ?> tags)

Notes:

  • The argument '450' in this call: wppa_have_photos('450'); is the column width you want the albums and photos to be displayed. If ommitted, the Column width as defined in Table I-A1 of the Settings page will be used.
    It is the same as size="450" in a shortcode.
  • It is required to have a page assigned to the search results (See Table IX-E12) that contains at least a landing page wppa shortcode like [wppa type="landing"][/wppa] in order to make the links from photos and albums work.
  • Two working examples for the theme twentyten and twentysixteen (used on theis site) are included in the plugin. See .../wp-content/plugins/wp-photo-album-plus/theme/search-2016.php
67(1)