Forums | Add the comic date near the comic title

You must be logged in to post Login Register

Search Forums:


 






Add the comic date near the comic title

New Issue
UserPost

4:19 am
February 21, 2011


siv0968

Italia

Member

posts 7

Post edited 4:20 am – February 21, 2011 by siv0968


Hi,
as I written on topic title, I'd like to add the comic date near the comic title in the file "comic-actions.php". This is the title code in that file:

<h2><a href="<?php the_permalink() ?>" title="<?php printf( __('Permalink to %s', 'sandbox'), the_title_attribute('echo=0′) ) ?>" rel="bookmark"><?php the_title() ?></a></h2>

I've tried to copy the code of the date in the "comic-rant.php" file:

<div class="entry-date"><abbr class="published" title="<?php the_time('Y-m-dTH:i:sO') ?>"><?php unset($previousday); printf( __( '%1$s – %2$s', 'stripshow' ), the_date( ", ", ", false ), get_the_time() ) ?></abbr></div>

but it ruins the structure of the title and the navigation buttons, and also make disappear the date under the rant title.

Do you have any suggestions on how to resolve this problem?

Bye!

6:59 am
February 21, 2011


GreenGel

Moderator

posts 21

I'm not entirely sure, but in order to to do this, you may be better off changing your theme files, I think, rather than changing a different file to try and add it. Changing the theme file you could just use the date function WordPress already uses. There's some information on that in the WordPress Codex, which gives a few options on how to do it and which function to use:

http://codex.wordpress.org/Fun…..e/the_date
http://codex.wordpress.org/Tem…..t_the_date
http://codex.wordpress.org/Tem…..s/the_time

7:17 am
February 21, 2011


Brad

Admin

posts 233

I suggest putting your code below the navigation buttons, not the date. Like this:

                <h2><a href="<?php the_permalink() ?>" title="<?php printf( __('Permalink to %s', 'sandbox'), the_title_attribute('echo=0') ) ?>" rel="bookmark"><?php the_title() ?></a></h2>
<ul class="stripshow-comic-navbar">
            <li class="first-comic"><?php first_comic('<span class="linktext">First Comic</span>','First Comic'); ?></li>
            <li class="previous-comic"><?php previous_comic('<span class="linktext">Previous Comic</span>','Previous Comic'); ?></li>
            <li class="next-comic"><?php next_comic('<span class="linktext">Next Comic</span>','Next Comic'); ?></li>
            <li class="last-comic"><?php last_comic('<span class="linktext">Last Comic</span>','Last Comic'); ?></li>
        </ul>
    </div>
    <div class="entry-date"><abbr class="published" title="<?php the_time('Y-m-dTH:i:sO') ?>"><?php unset($previousday); printf( __( '%1$s – %2$s', 'stripshow' ), the_date( '', '', '', false ), get_the_time() ) ?></abbr></div>

You'll probably want to give it your own CSS to make it look good. I like this:

div#comic-container div.entry-date {
    margin: -10px 0 0 10px;
    }

7:47 am
February 21, 2011


siv0968

Italia

Member

posts 7

Thank you Brad!!!
It works perfectly, both php and css code! :)

Now the problem is: with the date shown under the comic-title, the date in the comic-rant has disappeared (only the day/month/year, not the time)… like wrong re-called variable.

Bye!

8:38 am
February 21, 2011


GreenGel

Moderator

posts 21

I believe that is because of the use of "the_date" function which only shows up once per page. Try changing this code:

<div class="entry-date"><abbr class="published" title="<?php the_time('Y-m-dTH:i:sO') ?>"><?php unset($previousday); printf( __( '%1$s – %2$s', 'stripshow' ), the_date( ", ", ", false ), get_the_time() ) ?></abbr></div>

To this code:

<div class="entry-date"><abbr class="published" title="<?php the_time('Y-m-dTH:i:sO') ?>"><?php unset($previousday); printf( __( '%1$s – %2$s', 'stripshow' ), the_time( ", ", ", false ), get_the_time() ) ?></abbr></div>

.

Basically we just change the call to the_date() to be the_time() instead.

11:41 am
February 21, 2011


siv0968

Italia

Member

posts 7

Thanks GreenGel!
With your help I found a solution with this code:

<div class="entry-date"><abbr class="published" title="<?php the_time('Y-m-dTH:i:sO') ?>"><?php unset($previousday); printf( __( '%1$s', 'stripshow' ), the_time('d F Y')) ?></abbr></div>

I put the correct date format to the_time function, in order to have the same date format as the one near the title, and the problem is no more! :)

Thank you all again for these sooooo quick answers!!!



  • Donate

    While I don't maintain stripShow for a living, I wouldn't say no to a little donation, if you think the plugin is worth it...

  • Advertisements