Support » How-To and Troubleshooting » [Resolved] Restaurant's Daily special

[Resolved] Restaurant's Daily special

  • Hello.

    I’m building a website for a café/restaurant. That place has a daily special every day for 5 days a week. So actually what I’d thought it just could be a featured post plugin, but i haven’t found a plugin that shows specific pages on a specific day of week in a div.

    Monday -> show page_id=1
    Tuesday -> show page_id=2
    Wednesday -> show page_id=3
    Thursday -> show page_id=4
    Friday -> show page_id=5

    On Saturday and Sunday it should be empty, or show a picture or whatever.

    Can anyone help with this?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator keesiemeijer


    Try this
    Put this before the loop:

    $mydate = date("l");
    if($mydate == 'Monday') { $pageid= 1;}
    if($mydate == 'Tuesday') { $pageid= 2;}
    if($mydate == 'Wednesday') { $pageid= 3;}
    // etc etc


    It seems to work actually, but after that I have small problems with the layout.

    I have 4 divs on the front page: NEWS, DAILY SPECIAL, CONTENT, LINKS.

    After putting the php code to DAILY SPECIAL div it opens the queried page in the content div, not in the daily special. And when clicking on the links the content won’t change.

    What seems to be the problem?

    Moderator keesiemeijer


    Please provide a link to the page in question. without it there’s not much anyone can do to help.



    Forum Moderator

    What seems to be the problem?

    it might need a wp_reset_query(); at the end of the DAILY SPECIAL area, to reset the query string to ‘normal’ after the custom query.

    Sorry, can’t show it online yet, because I don’t have the host for this page yet.

    Anyhow, I can paste the code here as well:

    I have the index.php, with 4 divs:

    <?php get_header(); ?>
    <!-- GATHERING DIV END -->
    <div class="grid_3" id="gathering">
    <!-- GATHERING DIV END -->
    <div class="grid_3" id="dailyspecial">
    $mydate = date("l");
    if($mydate == 'Monday') { $pageid= 6;}
    if($mydate == 'Tuesday') { $pageid= 2;}
    if($mydate == 'Wednesday') { $pageid= 39;}
    <!-- CONTENT DIV START -->
    <div class="grid_4" id="content">
     <?php if (have_posts()) : ?>
      <?php while (have_posts()) : the_post(); ?>
      <div class="post" id="post-<?php the_ID(); ?>">
        <h2 class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
          <?php the_title(); ?>
        <div class="entry">
          <?php the_content('',TRUE,''); ?>
      <?php endwhile; ?>
      <div class="navigation">
        <div class="alignleft">
          <?php next_posts_link('« Older posts') ?>
        <div class="alignright">
          <?php previous_posts_link('Newer posts »') ?>
      <?php else : ?>
      <h2 class="center">No posts found.</h2>
      <?php endif; ?>
    <!-- CONTENT DIV END -->
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    + sidebar.php where i have the nav.

    I’d like to show the Daily Special and the content on the front page, but it seems to me that the query_posts(); has somekind of a conflict, because the called out page in Daily Special appears in the content div, not where I’d like to see it (dailyspecial div). + the navbar gets paralyzed.

    To alchymyth:
    wp_reset_query(); helped that much that the dailyspecial didn’t appear in the content div, but didn’t appear in dailyspecial to.

    So.. any ideas ?


    Think that got it to work.

    Here’s the code, that goes to the DAILY SPECIAL div:

    $mydate = date("l");
    if($mydate == 'Monday') { $pageid= 6;}
    if($mydate == 'Tuesday') { $pageid= /*page_id*/;}
    if($mydate == 'Wednesday') { $pageid= /*page_id*/;}
    if($mydate == 'Thursday') { $pageid= /*page_id*/;}
    if($mydate == 'Friday') { $pageid= /*page_id*/;}
    if($mydate == 'Saturday') { $pageid= /*page_id*/;}
    if($mydate == 'Sunday') { $pageid= /*page_id*/;}
        $featured = new WP_Query();
    <?php while ($featured->have_posts()) : $featured->the_post(); ?>
    <?php the_content(); ?>
    <?php endwhile; ?>

    I’m building a ‘daily special’ plugin for exactly this purpose. Should be ready soon. I’ll post back with a link once I do.


Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Resolved] Restaurant's Daily special’ is closed to new replies.
Skip to toolbar