Forums

Search is not working. (5 posts)

  1. verphiztual
    Member
    Posted 1 year ago #

    I have my custom search form.

    My problem is how to make my search form work? when I search any words on the website I created, nothing happens.

    Any body can teach me a step by step process to make my search form functioning? You can also give me a tutorial link about my problem.

    Thanks for those who may help me.

  2. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    You would need to turn your search form into a plugin.

  3. verphiztual
    Member
    Posted 1 year ago #

    thanks for the idea...
    Actually my search form is working now.. I put this code in my search.php

    <?php if (have_posts()) { while (have_posts()) : the_post(); ?>
    <div>
    <h3><a href="<?php the_permalink() ?>" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?> from <?php echo get_post_type(); ?></a></h3>
    <?php the_excerpt(); ?>
    </div>
    <?php endwhile; } else { ?>
    <p><?php _e('Nothing found, what meets your criteria.', 'basis'); ?></p>
    <?php } ?>

    My only problem is my search result. I don't want pages to include on my results. Just posts only.

  4. esmi
    Theme Diva & Forum Moderator
    Posted 12 months ago #

    Then exclude them using the is_page() conditional.

    <?php if (have_posts()) { while (have_posts()) : the_post(); if( !is_page() ) :?>
    <div>
    <h3><a href="<?php the_permalink() ?>" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?> from <?php echo get_post_type(); ?></a></h3>
    <?php the_excerpt(); ?>
    </div>
    <?php endwhile; } else { endif;?>
    <p><?php _e('Nothing found, what meets your criteria.', 'basis'); ?></p>
    <?php } ?>
  5. verphiztual
    Member
    Posted 12 months ago #

    no success... there is an error to your code.. i tried to transfer the endif; before the endwhile; like this:
    <?php endif; endwhile; } else { ?>

    there is no error but the pages are still included... :[

Topic Closed

This topic has been closed to new replies.

About this Topic