Community Forums › Forums › Archived Forums › Design Tips and Tricks › Author not displaying in meta data for single custom post type
Tagged: .post-info, Custom Post Type, missing author
- This topic has 5 replies, 2 voices, and was last updated 11 years, 9 months ago by marjwyatt.
-
AuthorPosts
-
April 19, 2013 at 3:34 am #36338marjwyattMember
I'm stuck and I'm hoping someone in here can help me understand what I'm doing wrong. This is a custom theme built on the sample child theme code offered here at StudioPress.
Here is my problem statement, with accompanying code...
The author shows up in archives displaying the custom post type but does not show up on the single display of that custom post type.
Here is a link to my custom post type declaration: http://pastebin.com/hNuGmcqK
Here is a link to my single-customtype.php: http://pastebin.com/Cpa2zwrtAt the bottom of that script, you'll notice two echo statements. The first one is displaying the author, and that's great. Here's that line of code:
`<?php echo 'This post was contributed by ' . get_the_author_meta('display_name') . ''; ?> `In the second echo, I am trying to use a variable to echo the same data, using the same function that is working in the above statement and nothing displays.
second echo's variable: `$another_artist = get_the_author_meta('display_name');`
second echo's output code:
`<?php echo 'This post was contributed by ' . $another_artist . ''; ?>`Here is a link to a single post type rendered by the above code at the development environment:
http://creativeconundrum.com/freshfaces/songs/blues/song-title/I'm truly baffled and I'm hoping that some smart person here can point me at the missing piece of the puzzle that my brain just can't seem to find.
Virtually Marj Wyatt
VirtuallyMarj.com | Twitter | Facebook | Google +April 19, 2013 at 10:41 am #36396daveyankMemberIt looks like you're executing lines 60-67 of single-customtype.php outside of the loop. Try executing those after the "while" statement on line 71.
April 19, 2013 at 11:23 am #36412marjwyattMemberThanks for your reply and suggestion, Dave, but those lines are not excluded. The variable $postid is being used successfully inside the loop to extract the custom fields and display them.
To show this to you (or anyone looking on), I am echoing the category slug just under the play button of the media. See this page:
http://creativeconundrum.com/freshfaces/songs/song-title/Any other ideas? I'm trying to get the author into the post info area and I just can figure out why it shows in archive displays and not on the single post itself...
Archive display link:
http://creativeconundrum.com/freshfaces/blues/
Virtually Marj Wyatt
VirtuallyMarj.com | Twitter | Facebook | Google +April 19, 2013 at 11:35 am #36415daveyankMemberThat's because get_the_category() can execute outside of the loop. get_the_author_meta() will only work outside the loop if you explicitly pass a userID to it. Here's one way to do it if you don't want to move that line of code:
`get_the_author_meta('display_name',get_queried_object()->post_author);`
April 19, 2013 at 11:51 am #36421marjwyattMemberHi Dave,
Nope ... moved that variable just after the while and again after the_post() and nothing has changed.
And I still would like to know why the author is missing from the post info right next to the date when it shows up in archives. That is really what I'm trying to accomplish. All the echoing inside the post itself was to see if the code knew who the author was.
Virtually Marj Wyatt
VirtuallyMarj.com | Twitter | Facebook | Google +April 19, 2013 at 5:08 pm #36460marjwyattMemberThanks Dave ... with your help, I was able to sort out a method to isolate the ID for the after post in content accordion menu but I still don't have an answer as to why the post info for my custom post type is missing information that it has for archives.
I'll soldier on and come back with the final & functional code.
Virtually Marj Wyatt
VirtuallyMarj.com | Twitter | Facebook | Google + -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.