Combining WP and WPPA+ Search results

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

  1. Make sure your wppa+ revision number is 4-1-1-002 or later. You will find your full wppa+ revision number on the Photo ALbums -> Settings admin page in the header. Example:
     

    Database revision: 411. WP Charset: UTF-8. Current PHP version: 5.2.17. WPPA+ API Version: 4-1-1-002.

    The full wppa+ revision number is the number after
    WPPA+ API Version:

    If you are not up to date and did all automatic updates, see this page for instruction how to re-install wppa+.

  2. Find the file search.php in your theme directory, and bring it in a text editor.
  3. Locate the line:

    <?php if ( have_posts() ) : ?>

    and change it into the next 3 lines:

    <?php $have_photos = function_exists('wppa_have_photos') && wppa_have_photos('450'); ?>
    <?php $have_posts = have_posts(); ?>
    <?php if ( $have_posts || $have_photos ) : ?>

  4. The next action is to find the place where the posts are printed.
    If it is:

    <?php while ( have_posts() ) { : ?>

    change it into:

    <?php if ( $have_posts ) while ( have_posts() ) { : ?>

    and add after the the closing of the while loop:

    if ( $have_photos ) wppa_the_photos();

    (make sure this code is within <?php ?> tags)

    If it is:

    get_template_part( 'loop', 'search' );

    change it into:

    if ( $have_posts ) get_template_part( 'loop', 'search' );
    if ( $have_photos ) wppa_the_photos();

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 item 1 of the Settings page will be used.
    It is the same as in &#37%size=…%%.
  • It is required to have a page assigned to the search results (See Table IX item 2) that contains at least &#37%wppa%% in order to make the links from photos and albums work.
  • A working example (that is used in this site) for the theme twentyten is included in the plugin. See …/wp-content/plugins/wp-photo-album-plus/theme/search.php

This entry was posted in Uncategorized. Bookmark the permalink.