Author not displaying in meta data for single custom post type

Community Forums Forums Design Tips and Tricks Author not displaying in meta data for single custom post type

This topic is: not resolved

This topic contains 5 replies, has 2 voices, and was last updated by  marjwyatt 1 year, 4 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #36338

    marjwyatt
    Participant
    Post count: 26

    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/Cpa2zwrt

    At 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 +

    http://creativeconundrum.com/freshfaces/songs/blues/song-title/
    #36396

    daveyank
    Participant
    Post count: 5

    It 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.

    #36412

    marjwyatt
    Participant
    Post count: 26

    Thanks 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 +

    • This reply was modified 1 year, 4 months ago by  marjwyatt.
    • This reply was modified 1 year, 4 months ago by  marjwyatt.
    • This reply was modified 1 year, 4 months ago by  marjwyatt.
    • This reply was modified 1 year, 4 months ago by  marjwyatt.
    #36415

    daveyank
    Participant
    Post count: 5

    That’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);`

    #36421

    marjwyatt
    Participant
    Post count: 26

    Hi 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 +

    #36460

    marjwyatt
    Participant
    Post count: 26

    Thanks 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 +

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.