Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #18231

    Hi guys,

    I love this forum, lot of useful stuff in here.

    However, I hope you could help me out with a small modification: I would like to remove the element that displays the date in single.php (around line 36-50) in certain posts. Here’s the code I’m talking about:

    <div class="date_container"><br />
    <span class='day'><?php the_time('d') ?></span><br />
    <span class='month'><?php the_time('M') ?></span><br />
    <span class='year'><?php the_time('Y') ?></span><br />
    <?php if($k_option['single']['acc_tw'] != '') { ?><br />
    <div class="tweetmeme"><br />
    <script type="text/javascript"><br />
    tweetmeme_source = '<?php echo $k_option['single']['acc_tw']; ?>';<br />
    tweetmeme_url = '<?php echo get_permalink() ?>';<br />
    </script><br />
    <script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"></script><br />
    </div><br />
    <?php } ?><br />
    <span class='date_container_bottom'></span><br />
    </div><!-- end date --><br />

    I suspect this could be easily done through wrapping the date element in some conditional php code and then use the custom fields to call for the function, much like method 2 does on this page: http://www.nannygoatsinpanties.com/how-tos/wordpress-how-to-remove-the-sidebar-for-specific-pages , only my skills with php are fairly limited.

    Do any of you guys have a suggestion as to how I could go about it? Thanks in advance!

    #98695

    Hi mizzquizz,

    I’m not sure if I understand what you are trying to do. If all you want to do is remove the date on a single page you could just remove the code from single.php completely.

    You could also do it via css a bit more easily by targetting the single-page class on the #top div. IE, something like this:

    #top.single-post .date_container {
    display: none;
    }

    Add that to your style.css at the very bottom and it will remove the date only from single post view.

    Regards,

    Devin

    #98696

    Hi Devin,

    the problem is that I only wish to remove the date element in <i>some</i> posts, as some parts of my site need to have a more static feel to them (my site is built up around the portfolio 4 column view). The method 2 on the page I linked to, seems a reasonably simple way to do this, using Custom FIelds to remove the date. I’m just not sure as to how I should wrap the date html code, or if there is another simpler way to do it.

    If I remove the code in single.php I think the date element will disappear from all posts, in stead of only some of them.

    I hope that I convey my idea properly :)

    #98697

    Replace:

    <div class="date_container"><br />
    <span class='day'><?php the_time('d') ?></span><br />
    <span class='month'><?php the_time('M') ?></span><br />
    <span class='year'><?php the_time('Y') ?></span><br />
    <?php if($k_option['single']['acc_tw'] != '') { ?><br />
    <div class="tweetmeme"><br />
    <script type="text/javascript"><br />
    tweetmeme_source = '<?php echo $k_option['single']['acc_tw']; ?>';<br />
    tweetmeme_url = '<?php echo get_permalink() ?>';<br />
    </script><br />
    <script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"></script><br />
    </div><br />
    <?php } ?><br />
    <span class='date_container_bottom'></span><br />
    </div><!-- end date --><br />

    with:

    <?php
    $removedate = get_post_meta(get_the_ID(), 'removedate', true);
    if( empty($removedate) ){ ?>
    <div class="date_container"><br />
    <span class='day'><?php the_time('d') ?></span><br />
    <span class='month'><?php the_time('M') ?></span><br />
    <span class='year'><?php the_time('Y') ?></span><br />
    <?php if($k_option['single']['acc_tw'] != '') { ?><br />
    <div class="tweetmeme"><br />
    <script type="text/javascript"><br />
    tweetmeme_source = '<?php echo $k_option['single']['acc_tw']; ?>';<br />
    tweetmeme_url = '<?php echo get_permalink() ?>';<br />
    </script><br />
    <script type="text/javascript" src="http://tweetmeme.com/i/scripts/button.js"></script><br />
    </div><br />
    <?php } ?><br />
    <span class='date_container_bottom'></span><br />
    </div><!-- end date --><br />
    <?php } ?>

    Then create a custom field, call it “removedate” and enter a value (you can eg enter 1 or yes, etc.).

    #98698

    Ah Dude, you’re a true hero! Thanks once again for helping me out!

    Cheers!

    #98699

    Hey,

    Good thing Dude fixed it. :)

    Regards,

    Ismael

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Disable date displayer with a custom field’ is closed to new replies.