Forums

[resolved] the_time() and author page url (5 posts)

  1. Zinneket
    Member
    Posted 1 year ago #

    Hi WordPressers,

    I'm currently trying to get WordPress to work on my freshly created website http://www.zinneket.be. So far it's been working great - WP is terribly easy to use, big up for that.

    I do have two questions at the moment, though.

    Firstly, I would like to format the timestamp of a blog post (and comment) as "17u03". I got as far as "17:03" by using

    <?php the_time('G:i') ?>
    but changing that to
    <?php the_time('Gui') ?>
    doesn't work (I'm no PHP expert but I can guess why it doesn't).
    I've tried instead
    <?php the_time('G') ?>u<?php the_time('i') ?>
    but that strangely renders as
    1294524187u03

    Can anyone tell me the right code?

    And then my second question: I'm trying to get the author's name of each post linked to the overview page of that author. The page with all of his posts on it, in other words. I've tried a couple of things. This gets me closest to what I'm looking for:

    <a href="<?php echo get_author_posts_url($id); ?>" class="auteur"><?php the_author() ?></a>

    but oddly that renders a wrong author id code (7 instead of 4). So when I click on it, I get the message indicating there's no posts to display.

    What's the right way to do this?

    Thanks very much!

  2. alchymyth
    The Sweeper
    Posted 1 year ago #

    try this:

    <?php the_time('G\ui'); ?>

  3. Rev. Voodoo
    Volunteer Moderator
    Posted 1 year ago #

    ="<?php get_author_posts_url(); ?>"

    nothing in the parenthesis should take you to the author page of the current post author

  4. Zinneket
    Member
    Posted 1 year ago #

    Thanks a lot alchymyth, that works perfectly!
    Rev. Voodoo, thanks. It doesn't work, though. When I use that code I get the following error:

    Warning: Missing argument 1 for get_author_posts_url(), called in /customers/zinneket.be/zinneket.be/httpd.www/wp-content/themes/zinneket/index.php on line 15 and defined in /customers/zinneket.be/zinneket.be/httpd.www/wp-includes/author-template.php on line 220

    Line 15 is of course:
    <div class="auteur">geschreven door <?php get_author_posts_url(); ?><?php the_author() ?> om <?php the_time('G\ui'); ?></div>

    (I removed the link so that the error is displayed; otherwise the text is linked to the error message)

  5. Zinneket
    Member
    Posted 1 year ago #

    Resolved! I asked the same question on StackOverflow and got the following correct answer. What I needed was the_author_posts_link(). That works like a charm. Thanks to everyone who has answered.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags