You must set your post counter outside your loop first before it will work. If you turn debugging on, you will get an undefined variable notice. You can do something like this just outside your loop before the loop starts
$postvariable = 1;
Alternatively you can make use of the build-in post counter, $wp_query->current_post
. It starts counting at 0, so to target the firts post, you can do
if( 0 == $wp_query->current_post ) {
//do something for first post
}
Related Posts:
- Sort results by name & asc order on Archive.php
- Default archive URL wordpress
- Increase number of posts in archive page
- How do I remove unwanted pages like archive, search, etc.?
- How do I place content on archive pages but not on main page?
- is_archive() returns false on the archives page
- What is archive.php used for?
- Archive by Year
- How do I visit archive-post.php?
- How do I make wp_get_archives show me months where only pages were created?
- Sort custom-posts in archive.php via meta-key?
- Create a month by month archive of pages (not posts)
- Making next_posts_link(); return posts by month
- Count posts for each year
- display archive as collapsing links
- How can I get the ID for an archive page? [closed]
- if in_category on archive.php
- Change behavior depending on content length
- Customize first page of category
- Cache previous versions of website?
- front end publishing not working on front-end page
- How to show static placeholder when less post elements in archive page?
- condition for only if is archive for default post type
- Show only post titles in archives?
- How to hide a post from archives
- How to disable monthly archive
- Displaying year, month and day archives differently
- What’s wrong with my date_query?
- How we display Archives for specific categories
- How to Create Custom Archive page
- Does only custom post type have post type archive pages?
- Modify text after post count
- Custom archives function
- Page is displaying blog archives
- terms_description and admin problem
- If one taxonomy contains the same term as another then display post
- Author archive doesn’t work [closed]
- Custom post type archive page thinks I’m not logged in
- How to conditionally check for author archive when is_author() fails to work because the author has no posts
- Is there a better way to do headings for (all) archives?
- Date Archive pages 404 error
- Constructing An if Statement with is_category(); in archive.php
- next and previous year month and day for archive page
- Get current title of archive.php
- How to show months in wordpress archive page?
- How to count the number of archives there are
- remove 2014 from wp_get_archives
- Get posts from a top category and group by child categories
- How can I make a page for post formats (specifically quotes) in wordpress 3.5
- Why is my archive.php redirecting to front-page.php?
- How to get post archives urls list without any markup?
- How can I loop only months foreach year?
- Only display archive subtitle on the first archive page
- Bootstrap Accordion with Dynamic content WordPress Archives Unique ID
- What do I need to style for the page after wp_get_archives?
- How to hide specific post type from archive?
- On my archives page, I can’t see my custom post types catergories
- Is there a way to multiply archive loop results sequentially?
- Add hour to archive link?
- WordPress archives in header -necessary?
- pre_get_posts conflict with archive posts
- Custom loop in addition to default on archive page
- Show Daily Archives after specific dates
- Custom archive pages without “the loop”
- Remove posts from two categories in Archive Page
- Show all 12 months regardless they have posts
- How to get the month argument from permalink in wordpress?
- Archive of year for some categories using the featured image
- Difference between $numpages & $max_page on archive pages
- Custom design calendar archive
- How to display dynamic additional contents on archive pages?
- Custom post archive page not opening 404 page
- How to disable date archives?
- How to show all the posts under the same Year in a page WordPress?
- Archive page no content to display
- Simplest way to archive a WordPress (and take down)?
- I want to be able to access archives to see how recently a post has been read: How can I do that?
- How to prevent archiving and search engine caching in a free WordPress blog?
- How to Completely Remove Archive Title a.k.a the_archive_title?
- Display archives based in post_format
- Show archives as a drop-down in the main navigation menu
- What’s wrong with default posts archive?
- How do I add a count to each month in this archive code?
- Parent and child relation code and display only first child list
- Get all posts from db between 2 specified months
- Display Day names with wp_get_archives instead of date
- Display future posts in archive
- Trying to hide subcategories which have categories without posts
- Archive by Year
- Exclude a specific category link from archive / front page
- Create archives by author role
- How to create an archive section of a WordPress site
- A problem with date archives
- Show monthly or daily archives
- Create page like custom post type list in WordPress
- WP Archive & Category Pages not filtering
- List archive year – post by post
- WordPress 3.6 – archive.php doesn’t get triggered [closed]
- How to have infinite scroll consider passed parameters?
- How to display the archive for native posts