Solved

Wordpress repeat certain post on certain day of the week

Posted on 2014-04-16
5
840 Views
Last Modified: 2014-04-17
We have regular specials of the day for our diner. I have created all the 7 posts. I am trying to see if there is a way that for example monday's special can show up on the homepage just on every monday of the month. and tuesday's just on tuesday's and so on.

Thanks and appreciate it
0
Comment
Question by:niceoneishere
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 40005775
So to be clear:

You don't want the post to repost, but instead get sticky for the correct day?
0
 
LVL 1

Author Comment

by:niceoneishere
ID: 40006554
I just want say french toast with fries special for monday to appear only on every monday on the home page once monday is over tuesday's post should appear on every tuesday

Thanks
0
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 500 total points
ID: 40007336
Okay, so the way to do it is to use custom fields and then some additional code to figure out which day is current and get the right post.

1) In your posts, create a custom field called "weekday" and give it the value of the day of the week ("Sunday", "Monday", etc).

2) Use the following code to initiate a new WP_Query that pulls the post that matches the current day of the week:


$currentday = date('l');
$query = new WP_Query( array( 'meta_key' => 'weekday', 'meta_value' => $currentday ) );

3) Create a loop on the desired page or template that uses the above to display the matching post.
0
 
LVL 1

Author Closing Comment

by:niceoneishere
ID: 40007682
Brilliant that worked perfect thanks
0
 
LVL 1

Author Comment

by:niceoneishere
ID: 40007718
Sorry just one more question how to add an and clause to it can query for day and as well as if its breakfast or lunch for example I tried this but did not work

	     <?php
        $currentday = date('l');
        $query1 = new WP_Query( array( 'meta_key' => 'weekday', 'meta_value' => $currentday && 'meta_key' => 'whatspecial', 'meta_value' => 'Breakfast'  ) );
         ?>
		 <?php if ( $query1->have_posts() ) : ?>
         <?php while ( $query1->have_posts() ) : $query1->the_post(); ?>
         <h2><?php the_title(); ?></h2>
		 <div><?php the_content(); ?></div>
        <?php endwhile; ?>
         <?php wp_reset_postdata(); ?>
        <?php else:  ?>
         <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
         <?php endif; ?>

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question