Community Forums › Forums › Archived Forums › Design Tips and Tricks › Losing all author_info when moving genesis_post_info
Tagged: genesis_post_info, missing author
- This topic has 4 replies, 2 voices, and was last updated 9 years, 3 months ago by
Brad Dalton.
-
AuthorPosts
-
May 29, 2014 at 1:59 pm #107352
Stefsull
MemberI'm using the Genesis Sample theme as a starting point along with Genesis HTML5 version. I've troubleshot this every way I can think of with no joy. I turn to you good people for further thoughts and ideas. I'll make this as clear as possible:
I'm trying to move my post info into a custom area after the header. Everything works fine except when adding the post_info back in (whether I filter the portions shown or not) the author_info is blank. Here's what I know...
If I don't remove the genesis_post_info from the default area in the theme (allowing it to be in both places), the default area still shows the author (and my filter removing comments/edit works). But the area I've added it back in to is missing the author. Here's an image of that: http://screencast.com/t/wxfz4ZWhOmV
I can create a filter and have the edit, time, comments, etc show up. Just not any of the three author shortcodes. (For the sake of troubleshooting, I removed any filtering for now.)
Once I remove the genesis_post_info, anywhere I add it back (whether it's in my original function or in an entirely new one by itself), the author is missing.
Here is my code:
//* Relocate Post Title and Post Info add_action( 'genesis_after_header', 'sk_relocate_post_title_info' ); function sk_relocate_post_title_info() { if ( is_singular('post' ) ) { remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 ); remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 ); remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); remove_action( 'genesis_entry_header', 'genesis_post_info', 12 ); echo '<div class="featured-single"><div class="wrap">'; genesis_entry_header_markup_open(); genesis_do_post_title(); genesis_post_info(); genesis_entry_header_markup_close(); echo '</div></div>'; } }
I've boiled this down as much as possible. I've removed every piece of the function one by one... put the genesis_post_info(); into a separate function... etc. All methods remove the author when the post_info is reapplied.
I can't link to the page since it's on my staging server, but all you'd see on inspection is empty author markup... all markup appears, but the text with the author's name does not.
Any thoughts? Halp?
May 29, 2014 at 2:29 pm #107360Brad Dalton
ParticipantYes because you can't use the get_the_author tag outside the loop.
You will need to use another author tag, not this one.
<?php $author = get_the_author(); ?>
Retrieve the post author. This tag must be used within The Loop.
Ref http://codex.wordpress.org/Function_Reference/get_the_authorIf you look in genesis > lib > shortcodes > post.php you'll find these tags:
$author = get_the_author(); $url = get_author_posts_url( get_the_author_meta( 'ID' ) );
Rebuild these shortcodes in your child theme with tags that work outside the loop and it will work.
May 29, 2014 at 2:39 pm #107361Stefsull
MemberOn it, Brad! I had no way to verbalize it since this is not my expertise, but I told my husband (also a developer) that it <b>must</b> be due to it not being "allowed" for some reason where it is. Thank you so much for the lifeline...
May 29, 2014 at 3:55 pm #107369Stefsull
MemberOK. For those following along at home (or running into this at a later date), after googling to figure out how to do what Brad described above, I found a great code snippet from someone who already did exactly what I needed. Thank you generous people for sharing! If you need to create a new shortcode to get the post author info to use outside The Loop, it's here:
http://ahjira.com/genesis-post-author-short-code-does-not-work-outside-the-loop/
(And thanks again for pointing me in the right direction, @braddalton.)
May 30, 2014 at 12:04 am #107424Brad Dalton
ParticipantAnother option if you want to create your own shortcode:
1. grab the code from Genesis
2. rename the function
3. rename the shortcode
4. rename the filter
5. replace the author tags with the ones which work outside the loopPretty much what Susanne did but you could also do it differently based on what you want to link to.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.