You have the header inside the Loop, so of course it prints once for each result. Put that outside the Loop proper.
if (have_posts()) { ?>
<img src="https://wordpress.stackexchange.com/questions/102754/banner.jpg" /><?php
while ( have_posts() ) {
the_post();
// print contents
}
}
Also, don’t use relative URLs in WordPress. You are in for all kinds of headache if you try.
Related Posts:
- A search for ‘0’ returns results
- If No Search Results, Show Posts from Alternate Search Query
- Custom search form to display users only
- How to get an array of years from all of the search results, and use it to filter by year the paginated loop?
- How to go about combining dropdowns / filter queries?
- Get search.php results in header.php?
- Filter the_posts doesn’t work on search page
- How to modify search.php to not show pages only show posts
- Include future posts in tags and in search
- Does search.php autofilter The Loop?
- How do I set the Stewart Search Template to return only published posts in the result
- Trying to get all links in my posts
- Work arounds for conditional checks inside the loop in search.php?
- Search – Check if post is a page on search page
- Eliminate duplicates in a foreach loop [closed]
- Jquery Slider for profile template
- Get excerpt using get_the_excerpt outside a loop
- Retrieve each widget separately from a sidebar
- Should I use loop in the single.php file?
- wp_list_categories: get latest featured_image of category
- Where should I use post_class()?
- get_the_foo() in the loop – does it perform another query?
- Exclude filter on front page
- category__not_in — anyway to use category name instead of id?
- Check if date of post is yesterday
- Exclude first 2 posts with meta_key from loop
- Fix inefficient loop breaks post.php on form submit
- Make a custom loop inside single.php with pagination
- Why do I get `Call to a member function have_posts() on a non-object `? [closed]
- Help with Changing loop.php?
- the_content() seems to block my ACF-code
- Pulling current post/page data into header.php
- Differentiate between posts and pages in search results
- Loop and Page template : my WP_query don’t take args
- How to split a loop into two columns
- Category Ajax call
- Transient loop issue
- popular post weekly and monthly
- WordPress Loop inside Loop?
- Get single post from tags array
- Apply an Incremental Counter in an Array Function
- What to and how to proceed with CPT to make DB small and efficient?
- Get all posts including sticky ones with get_posts(),setup_postdata(), and foreach loop?
- Latest Post Styled Different Than other Posts
- ACF custom field in [closed]
- Split wordpress loop to multiple layouts
- Woocommerce: How to display product price [closed]
- Update status of all posts in a category
- Loop counter style
- Can I add generic numbering HTML classes to items as a loop runs?
- Add “showing posts x to x of y” in custom post type paginated loop
- How to add add more properties to WP_Post object in search results loop
- Custom Post Type on Homepage – Studiopress Genesis Framework
- New loop vs widget
- Display a single category in blog section
- Query Nopaging action not having effect
- Yoast taking over my WordPress title tag [closed]
- Pagination broken after using 2 loops to show content
- Getting page slug
- How to get pagination to work with 2 wordpress loops
- Exclude page from loop results
- How is WordPress changing the content markup?
- Inserting CPT and static content at every X post, is this possible?
- loop through posts and display inserted media and post title as a link
- using update_user_meta to rank users
- Custom Blog Loop on Home Page
- Exceprt not displaying
- How do i create a list-posts-page?
- Exclude posts based on an array
- Displaying member join date on page
- Ascending order has strange effects on wordpress loop
- Is file_exists() compatible with timthumb.php? [closed]
- List ALL posts by author on author archive
- Using is_page_template inside loop
- How to show the last article in a different way in my blog?
- Can’t limit posts_per_page in loop
- Slug is changing when I use WP_Query in a metabox of a post
- How to fix pagination for custom loops?
- Check to see if a field is within an array in twig
- Custom loop not working in singular.php, working in other pages
- Strange problem with wp_get_attachment_image_src database (db) query count
- How to include posts from one category, into a separate category of posts?
- how do i make this loop work
- Archive sorted by month – separate
- Making a specific page wordpress compatable that is not index
- Humanmade | Custom meta box class: How to display a repeatable meta box group?
- Can’t print out returned value
- change the_content images for different sizes (Desktop, tablet, mobile)?
- Get query result before posts are displayed?
- WordPress Group By Problem
- Home page loop with pagination problem
- WooCommerce custom loop pagination on front page
- Tag custom loop show posts
- Problem with ms-thumb-frame-selected class in Master Slider
- I want the first post on my home page to be lengthier than the rest (example included)
- Loop with Custom Post Type Taxonomies and Interstitial Code
- Question about custom plugin
- loop mix my child-category and parent-category
- How can you make it so the comment box shows on some pages or posts but not all?
- Insert multiple custom components after x-number of posts