• Resolved dblinks

    (@dblinks)


    I have no trouble placing an ad at the top of a Search Results page (only on Search Pages). It would be nice to know if it’s possible to show 3 ads one at the top and 2 more after every 2nd or 3rd search result.

    I’m guessing you would say to put the php function in the search.php template. I tried putting:

    <?php if (function_exists ('adinserter')) echo adinserter (2); ?>

    into various areas of my search.php file but with no ad display results achieved.

    `// Prevent direct script access
    if ( !defined(‘ABSPATH’) )
    die ( ‘No direct script access allowed’ );
    ?>
    <?php get_header(); ?>

    <div id=”primary”>
    <div id=”content” role=”main”>

    <header class=”page-header”>
    <div class=”g1-hgroup”>
    <h1 class=”page-title”><?php printf( __( ‘Phrase: %s’, ‘g1_theme’ ), ‘<span>’ . get_search_query() . ‘</span>’ ); ?></h1>
    <h3 class=”page-subtitle”><?php echo __( ‘Search Results’, ‘g1_theme’ ); ?></h3>
    </div>

    </header>

    <?php if ( have_posts() ) : ?>
    <ul class=”search-results”>
    <?php while( have_posts() ): the_post(); ?>

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Spacetime

    (@spacetime)

    For the ad on the top try to use automatic display option Before Post.

    I’m assumnig the search page is a typical blog page with post excerpts.
    If it is ok to put ads above or below excerpts you simply set automatic display to Before / After excerpt and set Excerpt/Post number(s) to 2, 3 or anything that suits your needs.

    If you need to place ads between search results then you would have to modify theme file as you already tried. Maybe you were not editing the right file. In some themes search results are displayed using a standard blog page template (index.php). Again, in order to filter/limit PHP calls set Excerpt/Post number(s) to 2, 3 or anything that suits your needs.

    Hope this helps.

    Plugin Author Spacetime

    (@spacetime)

    Please use code tags to mark the code in the post.
    Otherwise you might break the page!

    Plugin Author Spacetime

    (@spacetime)

    In your case the results loop seems to be the code

    <?php while( have_posts() ): the_post(); ?>
    ......
    ......
    ......
    <?php endwhile; ?>
    Thread Starter dblinks

    (@dblinks)

    I must not have closed the /code. sorry, I don’t see that I can go back to edit the above.

    I followed your advice first to use “After” excerpt. Of course now I understand this works with a new ad unit targeting the same page. (finally got my head wrapped around that).

    Thanks for great support.
    Stu.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Search Results Page’ is closed to new replies.