ThemeShaper Forums » Thematic

Archive that indexes posts by title, author, date

(5 posts)
  • Started 9 years ago by Marcus
  • Latest reply from Marcus
  • This topic is resolved

Tags:

  1. Marcus
    Member

    Hi all --

    I'm using Thematic/Wordpress as a CMS to build a magazine-style site. I'd like my archive to list all posts in a bulleted list. I want each entry to include title, author and date, like so, where Title links to the post:

    * Title by Author _ Date

    I've tried several different tweaks that let me show the title and date, but I cannot get the correct author to display. Basically the problem is when I use the_author() or get_author_posts_link(), it always returns my name (the admin who published the post) instead of the name I set in the post as author. I think this must have something to do with the_author() only being usable, according to the Codex, inside the Loop. I've modified the archive loop and included the_author(), but maybe I'm not understanding 'the Loop' properly. I'm relatively new to this, so any help is appreciated.

    Thanks!

    Posted 9 years ago #
  2. Hi Marcus,

    it always returns my name (the admin who published the post) instead of the name I set in the post as author

    Where are you setting the author name?

    Posted 9 years ago #
  3. Marcus
    Member

    Here's the function from my child theme's functions.php that I was using before I tried the plugin. It works exactly like I need it to work, except for the aforementioned problem of returning the admin as the author regardless of who is set as the author of the post. Note that I'm only having this problem in my attempt to mod the archive. The author displays correctly in the posts themselves.

    function thematic_title_archives() { ?>
    <li id="title-archives" class="content-full">

      <?php
      global $post;
      $myposts = get_posts('numberposts=5&&category=-14');
      foreach($myposts as $post):
      ?>

    • "><?php the_title(); ?> by <?php the_author(); ?>, <?php the_time('F j Y'); ?>
    • <?php endforeach; ?>

    <?php }

    add_action('thematic_archives', 'thematic_title_archives', 5);

    Posted 9 years ago #
  4. Marcus
    Member

    Sorry, didn't post that code correctly. Let me try again.

    function thematic_title_archives() { ?>
      <li id="title-archives" class="content-full">
    
    <ul>
    		<?php
    		global $post;
    		$myposts = get_posts('numberposts=5&&category=-14');
    		foreach($myposts as $post) :
    		?>
    
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> by
    <?php the_author(); ?>, <?php the_time('F j Y'); ?></li>
    		<?php endforeach; ?>
    	</ul>
    <?php }
    
    add_action('thematic_archives', 'thematic_title_archives', 5);
    Posted 9 years ago #
  5. Marcus
    Member

    Aha! Cracked it. Instead of the_author, I did this:

    <a href="?author=<?php $curauth = get_userdata(intval($post->post_author)); echo ($curauth->ID); ?>"><?php echo ($curauth->user_login); ?></a>

    Tip of the hat to jbbrwcky over at wordpress.org, who doesn't know he solved my problem.

    http://wordpress.org/support/topic/269758

    Posted 9 years ago #

RSS feed for this topic

Reply

You must log in to post.