Forum Replies Created
-
AuthorPosts
-
NathanielMember
I 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.
NathanielMemberOh, 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;
NathanielMemberThanks 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?
NathanielMemberSo 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?
NathanielMemberAny help?
NathanielMemberNo problem. (Sorry, I thought I already had.)
NathanielMemberI'm sorry. It turns out that I don't even really know why I'm using the teasers plugin. I just deactivated it.
NathanielMemberThat includes the advice to add this line to the functions.php file in the child theme:
remove_action( 'genesis_loop', 'magazine_home_loop_helper' );
Any idea what that looks like for minimum pro?
NathanielMemberThanks, Davinder. It's been a few days since I've been able to try it out, but working on it right now the code to get WordPress to use the main-level style.css instead of the plugin's style.css doesn't seem to be working. The site loads fine, which makes me think that there isn't a major problem with adding it to the functions.php file, but no matter what I do to the Genesis Responsive slider formatting in the main-level style.css, there's no effect unless I actually delete the plugin's style.css. Is that what I'm supposed to do?
NathanielMemberThanks for your encouragement, Andrea! I went ahead and tried making the changes (exactly as outlined), and it turns out that there was one thing I had forgotten to do. I'm copy-pasting here in case anyone else comes along and is interested.
Here's the last piece of code I needed to add to get the widget to display properly:
if ( is_active_sidebar( 'home-slider') ) { //* Add Home-Slider Widget areas add_action( 'genesis_before_content_sidebar_wrap', 'minimum_home_slider_container', 15); }
I needed to add this to front-page.php inside the function function minimum_front_page_genesis_meta(). I added it at the very end, and then my test text-widget displayed! I can't believe how fast this actually ended up being. Now to see if I can get a slider to display correctly in that widget area...
NathanielMemberThanks, David. That fix helped a lot. I had experimented with trying to add margin to the individual text box elements, and it only made the problem worse. This was much more straightforward.
I'll tinker with the CSS myself from here on out.
NathanielMemberOh, maybe I also need to add this to the functions.php file?
//* Add support for structural wraps add_theme_support( 'genesis-structural-wraps', array( 'header', 'site-tagline', 'nav', 'subnav', 'home-featured', 'home-slider-container' //* added this line 'site-inner', 'footer-widgets', 'footer' ) );
Anything else?
NathanielMemberAndrea (or anyone else), this is my understanding of what I can do to add a new widget area beneath the home-featured widget areas. I'm going to explain what I plan on doing and why, and I would really appreciate any guidance. I'm going to wait to get feedback before I started editing my files. (Of course I have backups, but I don't even know if I'm on the right track and I don't want to start blundering around.)
Step 1: Create a container for the new widget area and also the new widget area in style.css
I just copied the existing code for .home-featured (which is a site container that holds all 4 of the home-featured widget areas) and renamed it .home-slider-container (instead of .home-featured)
.home-slider-container{ border-bottom: 5px solid #f5f5f5; margin-bottom: 60px; margin-bottom: 6rem; padding: 40px 0; padding: 4rem 0; }
Then I also added the site container that is the actual home-slider widget area. This is based on the .home-featured-1 site container. Only change: I made the width 100% instead of 25%.
.home-slider{ float: left; text-align: center; width: 100%; }
Step 2: Modify the front-page.php file to get these containers to actually show up on the front page.
So I was planning on inserting this right after the section that begins with the commend
//* Add markup for homepage widgets section
That's because--and this is a wild guess--I think that maybe the order of the stuff in front_page.php shows what order (vertically) they show up on the screen? I don't know. In any case, this is the code I was going to add:
//* Add markup for homepage slider function minimum_home_slider_container() { printf( '<div %s>', genesis_attr( 'home-slider' ) ); genesis_structural_wrap( 'home-slider-container' ); genesis_widget_area( 'home-slider', array( 'before' => '<div class="home-slider widget-area">', 'after' => '</div>', ) ); genesis_structural_wrap( 'home-slider', 'close' ); echo '</div>'; //* end .home-slider }
3. Register the widget in functions.php
So the last step is to go to the comment
//* Register widget areas
Where there's a list of widgets (like the home-featured-1, home-featured-2, etc.) and, at the end, tack on this code:
genesis_register_sidebar( array( 'id' => 'home-slider', 'name' => __( 'Home Slider', 'minimum' ), 'description' => __( 'This is the home slider section.', 'minimum' ), ) );
I would really appreciate any feedback that tells me if I'm on the right track of not. Thank!
NathanielMemberThanks, Andrea. I'm going to try and do that, but I have to admit that I don't actually know how. I've never added a widget area to this theme (or any theme), and I can't find any tutorials online that address my goal.
Do you have any pointers?
NathanielMemberThanks, Andrea! I'm still playing with the CSS to get the height exactly as I'd like it, but your recommendations finally got the height on the home-page to adjust and also showed me how to vertically center the tagline and it's widget area.
Awesome!
NathanielMemberJust wanted to chime in and say that I had the same question. I took sdbroker's advice (making changes only at line 518) and it worked for me. The image is shorter on the home page, and I didn't get any distortion to the tagline on post pages.
Thanks.
-
AuthorPosts