Because you’re using semicolons when you should be using colons after the if and the while 🙂
query_posts( 'year=2011' );
if ( have_posts() ):
while ( have_posts() ):
the_post();
the_title();
endwhile;
wp_reset_query();
endif;
That works just fine.
Related Posts:
- How can I fetch loop of post titles via AJAX?
- Inject post (from specific category) between posts in Loop
- get product attributes for current product and store it in a variable
- Installing wp3.2.1 on IIS; getting empty sessions
- How to add active class to custom menu using while loop and wp_list_pages
- Want to separate sections of posts. Can you restart loop?
- MySQL query performed 4 times inside loop
- Print html when custom field has value inside while loop
- Specific Loop For 2 Within Each
- Two posts in same div – WP loop
- Infinite-Scroll Plugin and Jetpack Infinite Scroll Plugin – Adding to “Thoughts” Theme
- Woocommerce, recognize the loop of related products
- Easiest way to show total number of subpages
- Custom Loop through category menu to include sub categories
- Output 2 items within the Loop
- How do I display the function the_content in this loop?
- How to get to a specific position in wp_query?
- Custom excerpt function re-factoring
- How can I show the post thumbnail from the most recent of a certain post type, in widget?
- How can I add pagination and how can I change thumbnail size?
- ACF page while loop breaks footer while loop
- Using foreach loop breaks
- Split loop into two columns, how to favor one side over the other
- Dynamic Stylesheet loads but doesn’t finish
- Filter Select results based on selection
- Loop with slider (slider not loading)
- How to hide all child pages with post_query?
- How to sort posts based on the value (number) of a post’s metadata?
- Show css depending on activity type in BuddyPress activity-loop [closed]
- Displaying Woocommerce Product Category in WordPress
- How can I add extra word in permalink when someone click download button?
- Increase offset while looping
- Woocommerce : Can’t get product info in loop
- remove post that has no content
- Checking array against author id in loop
- How do I Turn This Into An if statement?
- Changing the_posts_navigation() html output
- WP_Query fails despite having 1 post
- wp_query get the 2nd post
- Loop stopped working
- How to loop through all the attached images in a post, and get their url one by one
- I’m trying to create an array with a foreach loop, but the array only stores the last item [closed]
- Store post content in a php variable and output them using for loop
- How to add div blocks after certain set of post
- How do I remove a category from a wordpress loop>
- Show recent posts starting at a specific number archive
- How to get the last category name of a child category?
- WordPress query undefined offset in loop
- Issue with custom loop in Archive page
- WordPress loop by meta key that is an array? and how loop multiple arrays
- WP Query Leads to 502 Bad Gateway (Timeout Because Query Takes Too Long)
- home.php show blog posts as grid view
- Problem with custom loop and wp_list_pluck [closed]
- WordPress call post-ID in jquery
- How to extract information from a wp_query result?
- Echo array value
- List all anchor links on a page
- How to add title attribute to archive items
- Strip from or something better?
- How to break up php code to avoid echo
- Products listing check if meta checkbox is checked
- How to Create Carousel Indicators in PHP Loop using wp_get_attachment_url function?
- Get title of page containing post grid within the posts
- update_user_meta as multiple value but with same meta key
- Is there anyway I can call the year once?
- Responsive loop with 3 columns inside row then 2 columns
- cURL needing to loop through all “next_page”
- Display page content in different sections – based on page break block?
- Show the subcategory name based on current product
- How can I get my pagination loop to display the correct number of total pages?
- How do if all posts has this category ID then do this
- ERR_TOO_MANY_REDIRECTS / To Force SSL Logins and SSL Admin Access
- Date of last blog update for specific authors only?
- View tag description on page
- PHP for loop not working as intended
- Insert div after every three posts in home.php [duplicate]
- Display product attributes for current product
- For each 3 posts, show a different post type
- Using page template to fetch posts in page
- Create Customization Controls from Array
- WP Knowledge Base Theme bug – Subcategories and Articles, Need to change WP_Query
- ACF loop and php formatting
- How to have post count after each listed category
- Inserting A Feed and Sidebar into an HTML Page
- How can I put a custom field as the link of a button shortcode?
- What is the best way to get the first few post from WordPress in different divs using a loop?
- Transient Loop Not working as expected
- Advanced Taxonomy query, with 3 post types
- Why does a meta_query break this WP_Query?
- Conditional in foreach loop is outputting content twice
- Pagination in category.php not functioning
- is there away to hide php code in wordpress not to show in PAGES
- How to handle parent and child pages?
- Woocommerce linking variations
- I want to show image from custom field image on my custom page template
- Count the number of matching post names in foreach loop
- How to get posts by a certain author in inner loop using outer loop variable or post title WordPress
- How to show correct td of table tags in wp_query loop
- fetch from an external api call and display results in page
- How could I prevent using the same custom loop in a template file when I only need to change one meta_query parameter?