Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Wordpress repeat certain post on certain day of the week

Posted on 2014-04-16
5
Medium Priority
?
907 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 2000 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

Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Suggested Courses

650 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