Community Forums › Forums › Archived Forums › Design Tips and Tricks › Place Category Results Under Post
Tagged: after-post widget
- This topic has 9 replies, 2 voices, and was last updated 11 years, 5 months ago by bvags.
-
AuthorPosts
-
March 18, 2013 at 4:50 pm #29202bvagsMember
Hello Studio Press'ers!
I am trying to take the results of my "Recently Added" category, in the format that is shown in this link (http://www.crossfit-competitions.com/category/recently-added-events/), and have a number of them that I can determine appear underneath the comment section on any of my posts (ie. http://www.crossfit-competitions.com/2013/03/crossfit-worcestershire-5050-open-air-throwdown/).
I've tinkered around a bit, but not having any luck. Anyone have any idea what PHP I need and where to place it to get this to work?
Thanks! ...
-Brian
March 19, 2013 at 12:54 am #29321Dorian SpeedMemberOkay, let me see if I understand you correctly: you want to show, say, the three most recent posts in the category "Recently Added" underneath the comments section for each post? Is that right?
I would suggest adding an after-post widget, as explained in this post:
http://www.briangardner.com/email-newsletter-signup-box/If you want it to display after the comments instead of right after the post, try changing
add_action( 'genesis_after_post_content', 'custom_add_newsletter_box' );
to
add_action( 'genesis_after_comments', 'custom_add_newsletter_box' );
in the code Brian Gardner uses in his post.
Now, although he's using that area for an email newsletter signup, you could put any widget you wanted to into the "newsletter box" widget. You could install the Genesis Featured Widget Amplified plugin and use it to display three (or however many) posts from that "recently added" category.
To make them line up next to one another, you're going to want to target them in the CSS with percentages for the width. Something like #newsletter .featuredpost, if you're copying Brian's code.
Hoping this helps you get started.
Bringing websites Up to Speed
Firebug will light the way to understanding the secrets of the Internet!March 19, 2013 at 6:53 pm #29538bvagsMemberHi Dorian,
Thanks for looking into this for me. I have installed and activated the plugin, but when I make the changes to functions.php (I'm making the change to functions.php in my theme folder, right, not the WP functions.php?) I get an error when I refresh the site ...
Fatal error: Call to undefined function genesis_register_sidebar() in /home/bvags/public_html/crossfit-competitions-com/wp-content/themes/crossfit-competitions/functions.php on line 30
Is there something I have to do before I make the changes to the functions.php file?
Thanks ...
-Bri
March 20, 2013 at 2:24 pm #29792Dorian SpeedMemberFirst up, always make a backup before fooling with functions.php. If you aren't sure how to get that error off your site, what you need to do is re-upload the functions.php file via FTP - the original version of the file. If you'd made other customizations to functions.php, you can download it (also via FTP), remove the code you just added, and re-upload it, and it should put your site back the way it was.
You are making the changes in the right place, as far as what file you're editing. Did you get everything from Brian's code on his site?
Bringing websites Up to Speed
Firebug will light the way to understanding the secrets of the Internet!March 20, 2013 at 4:53 pm #29814bvagsMemberHi Dorian,
I was able to get my site back up and running, not a problem. As far as the code, yes, I copied everything that Brian had for the functions.php section. I also put in the CSS, but that shouldn't take my site down. Also installed the plugin he linked to.
This is currently what I have in my functions.php with the additional code from Brian, and the change you suggested ...
-Brian
cat_ID) { return $category->cat_name; break; }
}
}// Register newsletter widget area
genesis_register_sidebar( array(
'id' => 'newsletter',
'name' => __( 'Newsletter', 'custom-theme' ),
'description' => __( 'This is the newsletter section.', 'custom-theme' ),
) );// Add the newsletter widget after the post content
add_action( 'genesis_after_comments', 'custom_add_newsletter_box' );
function custom_add_newsletter_box() {
if ( is_singular( 'post' ) )
genesis_widget_area( 'newsletter', array(
'before' => '',
) );
}// include the breadcrumb nav tool
include(TEMPLATEPATH."/tools/breadcrumbs.php");// include the theme options
include(TEMPLATEPATH."/tools/theme-options.php");// include the dashboard widget
include(TEMPLATEPATH."/tools/sp_dashboard_widget.php");if ( function_exists('register_sidebars') )
register_sidebar(array('name'=>'Sidebar Top','before_title'=>'','after_title'=>''));
register_sidebar(array('name'=>'Sidebar Bottom Left','before_title'=>'','after_title'=>''));
register_sidebar(array('name'=>'Sidebar Bottom Right','before_title'=>'','after_title'=>''));
register_sidebar(array('name'=>'468x60 Header Banner','before_title'=>'','after_title'=>''));function the_content_limit($max_char, $more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
$content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
$content = strip_tags($content);if (strlen($_GET['p']) > 0) {
echo "";
echo $content;
echo " ".__("Read More", 'studiopress')." →";
echo "";
}
else if ((strlen($content)>$max_char) && ($espacio = strpos($content, " ", $max_char ))) {
$content = substr($content, 0, $espacio);
$content = $content;
echo "";
echo $content;
echo "...";
echo " ".$more_link_text."";
echo "";
}
else {
echo "";
echo $content;
echo " ".__("Read More", 'studiopress')." →";
echo "";
}
}
?>
March 20, 2013 at 4:54 pm #29815bvagsMemberhah, not sure that worked properly. I thought if I put everything inside code></code (removed the opening and closing brackets so they will show) it would show up as is, and un-parsed?
-Brian
March 29, 2013 at 4:03 pm #31983bvagsMemberHi Dorian,
Just wondering if you had any more ideas for me.
Thanks ...
-Brian
March 29, 2013 at 10:33 pm #32015Dorian SpeedMemberHi, Brian - sorry I missed this earlier. I would get rid of this:
// Register newsletter widget area genesis_register_sidebar( array( 'id' => 'newsletter', 'name' => __( 'Newsletter', 'custom-theme' ), 'description' => __( 'This is the newsletter section.', 'custom-theme' ), ) );
and try this:
genesis_register_sidebar( array( ‘id’ => ‘newsletter', ‘name’ => ‘Newsletter', ‘description’ => ‘This is the widgeted area after each post.’, ) );
although I think either should work.
Take a look at this post: How to Add a Widgeted Area (a.k.a., Sidebar)
Bringing websites Up to Speed
Firebug will light the way to understanding the secrets of the Internet!March 30, 2013 at 9:07 am #32074bvagsMemberHi Dorian,
Tried following your link, and followed the "After Post Subscribe Box" section, adding both chunks of text to my functions.php file in my theme folder.
I added the first chunk of code, added a blank space, and then added the second chunk of code. Saved and re-uploaded. And I am getting "Fatal error: Call to undefined function genesis_register_sidebar() in /home/bvags/public_html/crossfit-competitions-com/wp-content/themes/crossfit-competitions/functions.php on line 3".
Still not sure what I am doing wrong here.
Thanks ...
-Bri
March 30, 2013 at 11:15 am #32100bvagsMemberHi Dorian,
I actually was able to register the new widget here ...
if ( function_exists('register_sidebars') )
register_sidebar(array('name'=>'Sidebar Top','before_title'=>'','after_title'=>''));
register_sidebar(array('name'=>'Sidebar Bottom Left','before_title'=>'','after_title'=>''));
register_sidebar(array('name'=>'Sidebar Bottom Right','before_title'=>'','after_title'=>''));
register_sidebar(array('name'=>'468x60 Header Banner','before_title'=>'','after_title'=>''));
register_sidebar(array('name'=>'After Post Box','before_title'=>'','after_title'=>''));... and have the site not sh*t the bed when I re-uploaded it. And then I added the new action right before the end of the file ...
add_action( 'genesis_after_post_content', 'child_after_post_box' );
/** Loads a new sidebar after the post on single pages*/
function child_after_post_box() {if( is_single() ) {
echo '';
dynamic_sidebar( 'after-post-box' );
echo '';
}
}
?>... and the new widget appeared, and I added a basic text box in there w/ sample text, and added the CSS adjustments to style.css ... but am not seeing anything new appearing anywhere.
Not sure if I'm still missing something, or this method that I have tried just doesn't work.
-Bri
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.