ThemeShaper Forums » Thematic

[closed]

Trouble Adding Custom Bits Below Content on Homepage

(13 posts)
  • Started 3 years ago by nimrod
  • Latest reply from nimrod
  • This topic is not resolved
  1. nimrod
    Member

    I can't figure out how to add some custom content below the content on a static Home page via a function in a child theme.

    From what I gather, this simple code should work:

    function childtheme_home_bits() {
    
    if (is_home()) { ?>
    
    Custom Bits
    
    <?php }
    }
    
    add_action('thematic_belowcontent','childtheme_home_bits');

    However, nothing appears and I can't seem to find any other hooks that would allow me to place the custom bits below the content on a page. In fact, if I simplify and remove the if(is home) part, it still doesn't work.

    I'm using latest Thematic 0.9.6.2, in WP 2.9.2, and a clean child theme taken from the example folder in Thematic (with just the one function added that is mentioned above).

    Any help is much appreciated.

    Posted 3 years ago #
  2. azoomer
    Member

    I tried it out and couldn't get it working. Seems that thematic_belowcontent is not responding, whereas thematic_belowcontainer works.

    Posted 3 years ago #
  3. nimrod
    Member

    Hm, looking closer now, what I really need is a hook that goes beneath the post or the div class called "entry-content".

    This would still be within the "content" div and my content would still take advantage of the special styles set up there.

    Are there any hooks to accommodate that?

    Posted 3 years ago #
  4. nimrod
    Member

    Wondering if there's some other route I've missed on adding content to a page in a child theme via Thematic?

    It seems incredibly limiting if the preferred method of modifying templates is via the functions.php file but ONLY if there's a hook in the right place to add the content. There doesn't seem to be one that allows me to add in a block below the page content of the homepage.

    Am I missing some other simple method? I just want to add some content below the page entry on the home page. This shouldn't be so hard!

    Posted 3 years ago #
  5. azoomer
    Member

  6. nimrod
    Member

    Well, thanks, but it doesn't show any hooks in the right place (I've been staring at it for a while now!). I see thematic_postfooter in what looks like a useful place, but it either is busted or doesn't work on a static page.

    So if I use the following with thematic_postfooter instead, nothing happens on the homepage when a static Page is used (and not the normal loop of posts):

    function childtheme_home_bits() {
    
    if (is_home()) { ?>
    
    Custom Bits
    
    <?php }
    }
    
    add_action('thematic_postfooter','childtheme_home_bits');
    Posted 3 years ago #
  7. azoomer
    Member

    Okay i don't really have a clue but you could try is_front_page instead of is_home

    function childtheme_home_bits() {
    
    if (is_front_page()) { ?>
    
    Custom Bits
    
    <?php }
    }
    
    add_action('thematic_postfooter','childtheme_home_bits');

    I think that is what you need to use for a static homepage

    Posted 3 years ago #
  8. nimrod
    Member

    Very frustrating... just to test, I tried every action hook on the Blue Mandala Thematic Page Structure diagram. Every one works except for the one that might be the right location for me: thematic_postfooter.

    I even tried checking the WP Action Reference without much luck: http://codex.wordpress.org/Plugin_API/Action_Reference

    The promising one, loop_end, doesn't actually place the content at the end of the loop.

    So, again, I'm wondering if I'm barking up the wrong tree. Is there some other preferred method of dropping content into a page after the entry?

    Posted 3 years ago #
  9. nimrod
    Member

    Unfortunately, since both the thematic_postfooter and thematic_belowcontent don't seem to function predictably (and no other way has been brought up), I was obliged to opt for the old-fashioned solution of creating a new home template file.

    It's messier and redundant and requires me to remember that it's there if I change the home page, but at least it works.

    FYI on what I did to make it work in Thematic:

    I decided to add a block of three more home widgets below the entry content on the home page.

    So I created a basic raw page.php file that matches Thematic and added the widget section just below the content hooks at the bottom of the entry-content div like so:

    <?php
    /*
    Template Name: Custom Home
    */
    ?> 
    
    <?php get_header(); ?>
    
      <div id="container">
       <div id="content">
    
    <?php the_post(); ?>
    
        <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
         <h1 class="entry-title"><?php the_title(); ?></h1>
         <div class="entry-content">
    	<?php the_content(); ?>
    	<?php wp_link_pages('before=<div class="page-link">' . __( 'Pages:', 'your-theme' ) . '&after=</div>') ?>
    	<?php edit_post_link( __( 'Edit', 'your-theme' ), '<span class="edit-link">', '</span>' ) ?>
    		<div id="home_widgets">
    			<div class="wrapper">
    			<?php if(function_exists('dynamic_sidebar')): ?>
    						<div class="hr">_______</div>
    						<div class="home_i">
    			<?php if(dynamic_sidebar('Home I')) :else: ?><!-- widget_home_i --><? endif; ?>
    						</div>
    						<div class="hr">_______</div>
    						<div class="home_ii">
    			<?php if(dynamic_sidebar('Home II')) :else: ?><!-- widget_home_ii --><? endif; ?>
    						</div>
    						<div class="hr">_______</div>
    						<div class="home_iii">
    			<?php if(dynamic_sidebar('Home III')) :else: ?><!-- widget_home_iii --><? endif; ?>
    						</div>
    			</div><!-- #wrapper -->
    		<?php endif; ?>
    		</div><!-- #home_widgets -->
    	</div><!– .entry-content –>
        </div><!– #post-<?php the_ID(); ?> –>  
    
    <?php if ( get_post_custom_values('comments') ) comments_template() // Add a custom field with Name and Value of "comments" to enable comments on this page ?>  
    
       </div><!– #content –>
      </div><!– #container –>
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Next, I went in to the static home page I had created in WordPress and selected "Custom Home" as the page template. Of course, static home pages must set in WordPress' Settings -> Reading -> A static page (select below) radio button with the home page (or whatever you're calling it) selected in the Front page drop menu.

    Almost forgot: I did use the child theme functions.php for registering the home widgets:

    // Adds three widget areas on the Homepage just below content in confunction with custom home.php template file
    if ( function_exists('register_sidebar') )
    
    register_sidebar(array(
    		'name' => 'Home I',
    		'before_widget' => '<div id="%2$s" class="widget">',
    		'after_widget' => '</div>',
    		'before_title' => "\n<h3><span>",
    		'after_title' => "</span></h3>\n",
    	));
    register_sidebar(array(
    		'name' => 'Home II',
    		'before_widget' => '<div id="%2$s" class="widget">',
    		'after_widget' => '</div>',
    		'before_title' => "\n<h3><span>",
    		'after_title' => "</span></h3>\n",
    	));
    register_sidebar(array(
    		'name' => 'Home III',
    		'before_widget' => '<div id="%2$s" class="widget">',
    		'after_widget' => '</div>',
    		'before_title' => "\n<h3><span>",
    		'after_title' => "</span></h3>\n",
    	));
    Posted 3 years ago #
  10. Hi,

    Look in thematic>library>content-extensions.php for the list of action hooks that can be used with the content areas of thematic.

    There are lots of action hooks listed there that have not been updated on the bluemandala diagram.

    The source code is the one true diagram.

    Did you try the thematic_below_indexloop hook?

    -Gene

    Posted 3 years ago #
  11. nimrod
    Member

    Ah, that content-extensions.php file is an excellent reference. Being new to Thematic, I didn't know it existed.

    Just tried thematic_below_indexloop without success.

    I wonder what the deal is since nothing seems to work near the loop on the home page. But, like I mentioned before, I can take the sample child theme folder from the Thematic theme folder and add just the one function with the various hooks mentioned above without success.

    I even tried activating the empty test theme and removing the theme I've been working on just to see if it somehow affects the system. Same problem of no content results.

    Posted 3 years ago #
  12. nimrod
    Member

    Hmm, more strangeness: The home.php file (used to render the extra content widgets on the Home page) is affecting the blog or Posts page output.

    I'm simply using WordPress Settings -> Reading section to set the Home and Blog pages to Pages I've created (in this case I have a Page called "Home" set as the front page and a Page called "News" set for the Posts page).

    At first I noticed that three widgets showed up on the bottom of the News page with only the most recent post showing (none of the other posts appeared).

    I cleared out some extra code on the home.php file to stop that nonsense but noticed other parts are missing on the News page like Pagination. So I added the standard next and previous_posts_link hooks to the home.php file and pagination started working on the News page!

    I'm confused that a template file not selected for the News page would affect the News page.

    I assume this has to do with template hierarchy, but I know very little about it and what I glanced at online didn't help much. Any clues?

    Here goes all that extra time I always try to allot to these projects...

    Posted 3 years ago #
  13. nimrod
    Member

    Just noticed an odd success/failure: the following code in a blank test child theme for Thematic DOES show the custom content below the index loop.

    Only it's not on the home page I've set in WP Settings -> Reading -> Front Page drop menu. Rather, the custom content is being placed at the bottom of the loop on the News page which I've set for Posts.

    When I set the Reading config to Front page display your latest posts radio button, the custom content then shows on the home page.

    So, I would say that either is_home and/or theamtic_below_indexloop only targets the posts page (and not the static page that is set to be home).

    I suppose that makes sense since the static home page doesn't actually have a loop. Not sure what other hook to try though...

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.