Community Forums › Forums › Archived Forums › Design Tips and Tricks › Help Formatting Author.php (Minimum Pro)
Tagged: author page, minimum pro
- This topic has 6 replies, 2 voices, and was last updated 10 years, 1 month ago by Nathaniel.
-
AuthorPosts
-
February 6, 2014 at 8:12 pm #89049NathanielMember
I am trying to customize the layout of the author pages at my website. You can see what I've got so far here: http://difficultrun.nathanielgivens.com/author/nathaniel/
What I want to know is how to insert that info below the tagline. Do I have to edit the genesis loop to accomplish that? (If so, can someone point me in the right direction? I'm not even sure where I would edit that if I wanted to.)
Here's the entire code for my author.php (there's not much to it):
<?php $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author)); ?> <h2><?php echo $curauth->display_name; ?></h2> <?php echo $curauth->user_description; ?> <?php //* Run the Genesis loop genesis(); ?>
I've been using this page for reference so far: http://codex.wordpress.org/Author_Templates
http://difficultrun.nathanielgivens.com/author/nathaniel/February 8, 2014 at 6:31 pm #89405NathanielMemberAny help?
February 11, 2014 at 8:48 am #89806NathanielMemberSo I guess this is where I need to start working on loops. This is what I tried most recently:
<?php add_action( 'genesis_before_loop', 'include_author_info' ); function include_author_info() { $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author)); <h2>echo $curauth->display_name;</h2> echo $curauth->user_description; } //* Run the Genesis loop genesis();
So I'm basically just copy-pasting the code that generates the author info inside a function, then adding that function to the genesis_before_loop hook. And yet the result (not currently live on my site) is a totally blank page. Nothing loads at all.
Can anyone help point me in the right direction?
February 11, 2014 at 9:17 am #89822chillybinMemberA couple of issues with opening and closing php tags, try this snippet
<?php add_action( 'genesis_before_loop', 'include_author_info' ); function include_author_info() { $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author)); ?> <h2><?php echo $curauth->display_name; ?></h2> <?php echo $curauth->user_description; } //* Run the Genesis loop genesis();
We are a web design & development consultancy based in Singapore who specialise in all things WordPress & Genesis. | ChillyBin Web Design & Consultancy: http://www.chillybin.com.sg | Twitter: @chillybindesign
February 11, 2014 at 9:27 am #89825NathanielMemberThanks very much for the help, chillybin. I used your snippet instead. Good news: the page now loads. Bad news: none of the custom info displays. It's just as if Ihadn't included an author.php at all.
EDIT: I also tried moving it from genesis_before_loop to genesis_loop just to see if that changed anything. It did not.
Any further help?
February 11, 2014 at 9:33 am #89828NathanielMemberOh, I did one more thing. I tried modifying the code as follows:
add_action( 'genesis_before_loop', 'include_author_info' ); function include_author_info() { $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author)); ?> <h2>TEST<?php echo $curauth->display_name; ?></h2> <?php echo $curauth->user_description; }
The word "TEST" did appear where I expected it to. So I guess there's something wrong with these snippets:
echo $curauth->display_name;
and
echo $curauth->user_description;
March 6, 2014 at 9:12 am #93666NathanielMemberI am still working on this problem. Still no resolution. I've done lots more research, however, and I have a better understanding of what I'm trying to do. Here is my current code (less some comments). Can anyone tell me why it is not working?
<?php // this is the function I want to use to output my stuff. function include_author_info($author_info) { echo $author_info; } // now we want to add this action to the Genesis loop add_action( 'genesis_before_loop', 'include_author_info', 5, 1); // now I populate the data I will feed to the function // first: set curauth based on the current author $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author)); // next: store the curauth name $user_name = $curauth->display_name; // additionally: store the user bio for the curauth $user_bio = $curauth->user_description; // concatenate the name and bio into one formatted string $formatted_user_info = "<h2> " . $user_name . "</h2><br /><p>" . $user_bio . "</p>"; // for testing purposes, I output the concatenated and formatted name/bio echo $formatted_user_info; // finally, I execute the action do_action('include_author_info', $formatted_user_info); //* Run the Genesis loop genesis();
It seems simple. I know that the variable $formatted_user_info has exactly the string that I want to display. All I want is to display it using the genesis_before_loop hook. It seems like this would be a fairly innocuous thing to do: use a hook to display some text. But (as you can see on my site), it's not working.
Any help would be appreciated.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.