lifestylevast.blogg.se

Wordpress move date up by one year
Wordpress move date up by one year





wordpress move date up by one year

wordpress move date up by one year

Like the first one, the second loop uses the query_posts() function with the post_not_in parameter. Just before the loop starts, I create a PHP array named $ids, which will receive all IDs of the posts returned by this loop. The showposts parameter allows you to get the specified number of posts. The first loop starts with the very useful query_posts() function, which allows you to specify a wide range of parameters to be used by the loop. Save your index.php file and admire the results!

wordpress move date up by one year

Once that’s done, it’s time to apply our second loop and get all posts, excepted the ones we have already outputted in the first loop: $ids))

#Wordpress move date up by one year code

Open the index.php file, and paste the following code to output your “featured” posts: Nothing hard here: we’re just going to get the eight most recent posts using the showposts parameter. While using two loops is very easy to do, preventing duplicate posts from displaying is not… until, that is, you learn this easy method of preventing them. Most modern themes and all “magazine” themes display at least two loops on the blog’s home page these can be used, for example, for a “featured posts” section. Use More Than One Loop On A Page, Without Printing Duplicate Posts

  • WordPress loop: Get posts published between two particular datesĢ.
  • Then, before starting the loop, the filter_where() function is hooked into WordPress’ post_where() function.Īs a result, the “ WHERE” clause contained in the filter_where() function is added to the end of the SQL query contained in the post_where() function, which means that the loop will return posts published only between the two dates specified in the filter_where() function. To achieve this hack, I first create a function named filter_where(), which contains an SQL “ WHERE” condition. Don’t forget to replace the dates in the example with yours. Simply paste the following code wherever in your theme you’d like to display the list of posts published between two dates. Unfortunately, getting posts published between, for example, March 17 and May 3 isn’t that easy. The loop and the query_posts() WordPress function allow you to easily retrieve a list of posts published in a specific week or month.







    Wordpress move date up by one year