Two Wordpress search results pages -


i have 2 different search results depending on page, user on.

i have duplicated how previous search contents display, added code want staff search show, , put if statement around it.

if user on page 'staff' - show else show this.

i cant seem if-statement work, appreciated.

edit

this original working code, before put if statement in, try , create set of results staff searching specific page.

<?php if ( is_home() ) {     $paged = get_query_var( 'page' ) ? get_query_var( 'page' ) : get_query_var( 'paged' );      $args = array(         'showposts' => (int) get_option('trim_homepage_posts'),         'paged' => $paged,         'category__not_in' => (array) get_option('trim_exlcats_recent'),     );     query_posts( apply_filters( 'et_home_args', $args ) ); } ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <article class="entry post clearfix preownedsearch">      <h2 class="et_pt_portfolio_title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>     <?php          $index_postinfo = get_option('trim_postinfo1');         if ( $index_postinfo ){             echo '<p class="meta">';             et_postinfo_meta( $index_postinfo, get_option('trim_date_format'), esc_html__('0 comments','trim'), esc_html__('1 comment','trim'), '% ' . esc_html__('comments','trim') );             echo '</p>';         }     ?>      <div class="post-content clearfix">         <?php             $thumb = '';             $width = apply_filters('et_image_width',260);             $height = apply_filters('et_image_height',170);             $classtext = '';             $titletext = get_the_title();             $thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext,false,'entry');             $thumb = $thumbnail["thumb"];         ?>         <?php if ( '' != $thumb && 'on' == get_option('trim_thumbnails_index') ) { ?>             <div class="featured_box filter">             <a href="<?php the_permalink(); ?>">             <?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, $classtext); ?>                   </a>                 </div>  <!-- end .featured_box -->         <?php } ?>     </div> </article>  <!-- end .post-->  <?php endwhile; if (function_exists('wp_pagenavi')) { wp_pagenavi(); } else { get_template_part('includes/navigation','entry'); } else: get_template_part('includes/no-results','entry'); endif; if ( is_home() ) wp_reset_query(); ?> 

this coding after i've put if-statement in -

<?php if ( is_home() ) {     $paged = get_query_var( 'page' ) ? get_query_var( 'page' ) : get_query_var( 'paged' );      $args = array(         'showposts' => (int) get_option('trim_homepage_posts'),         'paged' => $paged,         'category__not_in' => (array) get_option('trim_exlcats_recent'),     );     query_posts( apply_filters( 'et_home_args', $args ) ); } ?>  <?php if (is_page('stock-managers')) { ?>  <article class="entry post clearfix preownedsearch">      <h2 class="et_pt_portfolio_title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?><?php the_meta(); ?></a></h2>     <?php          $index_postinfo = get_option('trim_postinfo1');         if ( $index_postinfo ){             echo '<p class="meta">';             et_postinfo_meta( $index_postinfo, get_option('trim_date_format'), esc_html__('0 comments','trim'), esc_html__('1 comment','trim'), '% ' . esc_html__('comments','trim') );             echo '</p>';         }     ?>      <div class="post-content clearfix">         <?php             $thumb = '';             $width = apply_filters('et_image_width',260);             $height = apply_filters('et_image_height',170);             $classtext = '';             $titletext = get_the_title();             $thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext,false,'entry');             $thumb = $thumbnail["thumb"];         ?>         <?php if ( '' != $thumb && 'on' == get_option('trim_thumbnails_index') ) { ?>             <div class="featured_box filter">             <a href="<?php the_permalink(); ?>">             <?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, $classtext); ?>                   </a>                 </div>  <!-- end .featured_box -->         <?php } ?>     </div> </article>  <!-- end .post-->  <?php } else { ?>     <article class="entry post clearfix preownedsearch">      <h2 class="et_pt_portfolio_title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>     <?php          $index_postinfo = get_option('trim_postinfo1');         if ( $index_postinfo ){             echo '<p class="meta">';             et_postinfo_meta( $index_postinfo, get_option('trim_date_format'), esc_html__('0 comments','trim'), esc_html__('1 comment','trim'), '% ' . esc_html__('comments','trim') );             echo '</p>';         }     ?>  <div class="post-content clearfix">         <?php             $thumb = '';             $width = apply_filters('et_image_width',260);             $height = apply_filters('et_image_height',170);             $classtext = '';             $titletext = get_the_title();             $thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext,false,'entry');             $thumb = $thumbnail["thumb"];         ?>         <?php if ( '' != $thumb && 'on' == get_option('trim_thumbnails_index') ) { ?>             <div class="featured_box filter">             <a href="<?php the_permalink(); ?>">             <?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, $classtext); ?>                   </a>                 </div>  <!-- end .featured_box -->         <?php } ?>     </div> </article>  <!-- end .post-->  <?php } endif; ?>     <?php endwhile; if (function_exists('wp_pagenavi')) { wp_pagenavi(); } else { get_template_part('includes/navigation','entry'); } else: get_template_part('includes/no-results','entry'); endif; if ( is_home() ) wp_reset_query(); ?> 

edit 2 match

<?php if ( is_home() ) {     $paged = get_query_var( 'page' ) ? get_query_var( 'page' ) : get_query_var( 'paged' );      $args = array(         'showposts' => (int) get_option('trim_homepage_posts'),         'paged' => $paged,         'category__not_in' => (array) get_option('trim_exlcats_recent'),     );     query_posts( apply_filters( 'et_home_args', $args ) ); } ?>  <?php if (have_posts()) : while (have_posts()) : the_post(); ?>  <?php if ($post->post_name('stock-managers')) { ?>  <article class="entry post clearfix preownedsearch">      <h2 class="et_pt_portfolio_title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?><?php the_meta(); ?></a></h2>     <?php          $index_postinfo = get_option('trim_postinfo1');         if ( $index_postinfo ){             echo '<p class="meta">';             et_postinfo_meta( $index_postinfo, get_option('trim_date_format'), esc_html__('0 comments','trim'), esc_html__('1 comment','trim'), '% ' . esc_html__('comments','trim') );             echo '</p>';         }     ?>      <div class="post-content clearfix">         <?php             $thumb = '';             $width = apply_filters('et_image_width',260);             $height = apply_filters('et_image_height',170);             $classtext = '';             $titletext = get_the_title();             $thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext,false,'entry');             $thumb = $thumbnail["thumb"];         ?>         <?php if ( '' != $thumb && 'on' == get_option('trim_thumbnails_index') ) { ?>             <div class="featured_box filter">             <a href="<?php the_permalink(); ?>">             <?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, $classtext); ?>                   </a>                 </div>  <!-- end .featured_box -->         <?php } ?>     </div>  </article>     <!-- end .post-->   <?php else : ?>       <article class="entry post clearfix preownedsearch">      <h2 class="et_pt_portfolio_title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>     <?php          $index_postinfo = get_option('trim_postinfo1');         if ( $index_postinfo ){             echo '<p class="meta">';             et_postinfo_meta( $index_postinfo, get_option('trim_date_format'), esc_html__('0 comments','trim'), esc_html__('1 comment','trim'), '% ' . esc_html__('comments','trim') );             echo '</p>';         }     ?>      <div class="post-content clearfix">         <?php             $thumb = '';             $width = apply_filters('et_image_width',260);             $height = apply_filters('et_image_height',170);             $classtext = '';             $titletext = get_the_title();             $thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext,false,'entry');             $thumb = $thumbnail["thumb"];         ?>         <?php if ( '' != $thumb && 'on' == get_option('trim_thumbnails_index') ) { ?>             <div class="featured_box filter">             <a href="<?php the_permalink(); ?>">             <?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, $classtext); ?>                   </a>                 </div>  <!-- end .featured_box -->         <?php } ?>     </div> </article>  <!-- end .post-->  <?php endif; ?>  <?php endwhile; if (function_exists('wp_pagenavi')) { wp_pagenavi(); } else { get_template_part('includes/navigation','entry'); } else: get_template_part('includes/no-results','entry'); endif; if ( is_home() ) wp_reset_query(); ?> 

your php syntax wrong.

php syntax check: parse error: syntax error, unexpected 'endif' (t_endif) in code on line 7 <?php } endif;?> php syntax check: errors parsing code

with removing endif;you're go

<?php if (is_page('staff')) { ?>  <article class="entry post clearfix">     <-- title / thumbnail / price / description coding --> </article>    <?php } else { ?>    <article class="entry post clearfix">     <-- title / thumbnail / description coding --> </article>   <?php }  ?> 

learn more php's alternativ syntax

see explanation of using if(condition){}and if(condition):endif; @ answer

edit:

if you're using is_page within loop, it'll allways false /see source.

instead compare chosen value (here it's staff) other field of current post/page.

<?php if ( $post->post_name=='staff' ) { ?>  <article class="entry post clearfix">     <-- title / thumbnail / price / description coding --> </article>    <?php } else { ?>    <article class="entry post clearfix">     <-- title / thumbnail / description coding --> </article>   <?php }  ?> 

edit no.2:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>      <?php if ($post->post_name('stock-managers')) { ?>          <article class="entry post clearfix preownedsearch">          </article>  <!-- end .post-->      <?php else : ?>             <article class="entry post clearfix preownedsearch">           </article>  <!-- end .post-->      <?php endif; ?>  <?php endwhile; ?> 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -