You should call the_post
only inside the loop, or call rewind_posts()
before actually starting the loop.
sidenote: you are doing it totally wrong. don’t reinvent the wheel, look in the codex how to write a theme or use one of the bundled default themes as a base to your theme. No sane person starts to code a theme from zero.
Related Posts:
- The proper way to include/require PHP files in WordPress
- How to remove search bar from a wordpress theme? [closed]
- How to add custom css file in theme?
- get_template_part vs action hooks in themes
- Do I actually need to link my theme’s style.css in the theme files
- Get url of thumbnail from the media uploader
- My child theme doesn’t work Error: “The parent theme is missing. Please install your parent theme”
- Should I use set_transient or update_option?
- Theme file for all pages that are a child of a specific page
- Template for individual post designs
- Best practice way to implement custom sections into a WordPress theme
- How to show next Post Thumbnail image in WordPress using current post id
- Pushing updates to your premium theme
- Where can I find a good reviewed collection of Twenty Ten child themes?
- Front End Post Submit Form
- How do I remove RSS feeds from themes?
- CSS in child theme not overriding the parent theme [closed]
- Advantages of using instead of wp_enqueue_style()?
- Style.css redirects to 404 Page not found
- Displaying wp menus by name without using theme locations
- How to add dynamic inline style?
- Optimal solution to develop a wordpress theme?
- How to add suggest plugin to theme?
- Create a theme by combining a parent and a child theme
- Prevent update check for specific theme
- Do I really need the div class entry?
- Am I supposed to create a child theme for every theme I use?
- using wordpress without javascript
- Theme Check: Could not find post_class
- Why wp_head() function not loading style.css?
- Implement advanced search
- Override theme programmatically
- Set multiple templates per post
- WP 3.1 upgrade breaks AutoFocus+ theme
- How can I display/hide certain content based on a Theme Option field?
- create-guten-block in wordpress theme?
- Custom WordPress Theme – Search not working on posts
- How can I make that when I clic on one of the menu items, that page shows only posts with the same category?
- Theme Splash Image within the “Appearance -> Themes” control panel [duplicate]
- Theme Loading Into Dashboard
- How to make theme elements customizable in wordpress?
- How to add “Template” option in page attributes panel?
- Which html elements should be styled in wordpress theme
- Folder name for a pro version of a WordPress.org theme?
- Admin: sub menu doesnt display under apperance when activate my themes
- Is it possible to include an HTML flat-file website inside a WordPress theme?
- Overrite parent functions using child functions
- How can I change the theme of different posts using a plugin?
- Create a child theme from multiple themes
- Are seven additional image sizes are too many?
- How can I use the WordPress Loop and Pagination in multiple instances but different scenarios throughout my site?
- registering a global template wordpress 6.0
- Post and page content not displaying in search results
- Copying the theme style files and images to duplicate the website but with a difference
- Why still output /wp-content/themes/twentynineteen?
- I have WordPress setup on primary domain, how do I set it up on its subdomain using the same database?
- How to set Post meta-box defaults based on the choices made by user in Customizer?
- Theme Action to hook for one time only function [duplicate]
- get_header action not working
- How do I include a partial from a directory below a wordpress theme directory?
- Remove h1 from 2015 theme
- Some doubts about WordPress handle the horizontal main menu visualization
- first excerpt fine, subsequent post excerpts shift to the right instead of displaying vertically [closed]
- HTTP Error when uploading images over specific dimensions
- Why is the `if else` not working?
- showing all recent posts in theme
- iPad WordPress theme?
- custom Background not showing after upgrade?
- Rolling your own WordPress Themes
- List categories of a post hierarchically?
- Custom search template is showing 404 when adding query string
- How do I restructure the comment HTML layout?
- PHP Parse error: syntax error, unexpected ‘endwhile’ (T_ENDWHILE), expecting elseif (T_ELSEIF) or else (T_ELSE) or endif (T_ENDIF) on line 124
- Is it possible to show sort page excerpt in search.php
- Theme: dropdown hover menu not showing up in IE/Edge
- Problem with pagination link (error 404)
- How to display home page last modified date in anywhere of wordpress theme?
- how to ensure responsiveness in wp themes? [closed]
- home is not working in wordpreess
- Is a multipurpose theme an alternative to modifying or creating a theme from scratch?
- Local theme changes upload on server but theme changes not showing
- WooCommerce – edit templates
- How to dowload and edit content of a website
- New created Theme leads to malfunctioning Xampp Apache –> functions.php is cause
- New theme HTML5 Support for Search in WordPress 4.4
- Best strategy for providing theme options using customizer
- Next post in category
- Safe way to echo wp_trim_words
- How can I demonstrate themes well?
- How to update my own theme?
- WordPress custom jquery not found
- The normal loop with different styles doesn’t work in search.php
- Displaying Tags for the Page I’m On?
- Custom link color or stylesheets
- How to remove proudly created by WordPress in theme?
- Roll my own theme or customize an existing one [closed]
- Why do some sites show themes/”themename” as the only theme?
- How to make a multilingual wordpress site to be translated one-to-one without much effort and without using translate?
- Is there a way to have WordPress autodetect page templates in the page-templates directory and any sub-folders?
- My wordpress site memory exhausted more than 1GB trying to debug with default