• I’m working with a student newspaper that’s setting up on WordPress and one of the issues we face is that not all authors of articles are necessarily users on the system.

    Previously, they’d been just typing the author information at the top of the story, but there are many situations in which that just looks awful.

    So, I figured the easiest thing to do would be set up a custom author field for authors who are not users and set it to show when a full article is displayed.

    I created a custom field key “author” and then modified the part of single.php that displays the user who posted the article with the following code

    By
    			<?php
                $author = get_post_meta($post->ID, "author", $single = true);
                if ( $author ) {
                echo $author;
                } else {
                the_author_posts_link();
                }
                ?>

    Now it works just fine, in terms of displaying what we need, but when the author is a user, their name can be clicked on and the reader can see a list of all of their posts. However, I cannot figure out how to set up a custom author value to do the same.

    From what I’ve seen I know that taxonomies might be able to do it, but I can’t figure out how to implement it in a method that will allow my users to enter author names as values within the Edit Post screen.

    I’ve also seen this code

    <?php $series = get_post_meta($post->ID, 'series', true); if($series): ?>
    	<div id = "series">
    		<h2>Read all <em><?php echo $series; ?></em> series</h2>
    		<ul>
    		<?php $chapters = get_posts('numberposts=-1&meta_key=series&orderby=date&order=ASC&meta_value='.$series); foreach($chapters as $chapter):?>
    			<li><?php if($chapter->ID != $post->ID): ?><a href ="<?php echo get_permalink($chapter->ID); ?>"><?php endif; echo $chapter->post_title; ?></a></li>
    		<?php endforeach; ?>
    		</ul>
    	</div>
    <?php endif; ?>

    which lists posts by meta_key and meta_value on a pre-existing post. This seems half-way there. What I need is for it to do something similar, but link to and display the posts on a separate page.

    I’ve been going crazy trying to figure this out, I feel that there must be a solution out there, but it is just escaping me.

    Any help with this would be greatly appreciated.

    Thanks.

  • The topic ‘Linking a display of a custom field value to list of posts with value’ is closed to new replies.