ThemeShaper Forums » Thematic

[closed]

Filter thematic loop

(16 posts)
  • Started 4 years ago by Jamie Mitchell
  • Latest reply from jcollier
  • This topic is resolved

Tags:

  1. Jamie Mitchell
    Member

    hey all...

    i'm a little confused with the new thematic.

    i need to filter the 'read more', what i used to to was just remove it in the index and add my own variation, that was easy, but it's all different in there now.

    how do i hook into the loop, say if i want to change the read more, or perhaps add a custom field or some other modification.

    many thanks in advance.

    Posted 4 years ago #
  2. Hi,

    .. for the 'read more':

    function my_moretext() {
        return "Whatever you want to tell your audience";
    }
    add_filter('more_text', 'my_moretext');

    .. for the_excerpt / the_content:

    function my_content($content) {
        if (is_category()) {
            $content = 'full';
        }
        return $content;
    }
    add_filter('thematic_content', 'my_content');

    .. the post:

    function my_post($content) {
        if (is_category()) {
            $content .= 'Add whatever you want to show your audience';
        }
        return $content;
    }
    add_filter('thematic_post', 'my_post');

    If you need to change the general behaviour inside the loop, remove the loop from the action hook and add your own action. Or you could add a action before or after the loop.

    Chris

    Posted 4 years ago #
  3. Jamie Mitchell
    Member

    thanks Chris.

    your always a great help when i get stuck

    :)

    Posted 4 years ago #
  4. Here's my attempt at removing the "Category Archives:" text in the category template using Acamas child theme: :


    <?php
    function child_page_title($content) {
    if (is_category()) {
    $content = '<h1 class="page-title">';
    $content = __('', 'thematic');
    $content = ' <span>';
    $content = single_cat_title('', TRUE);
    $content = '</span></h1>' . "\n";
    if ( !(''== category_description()) ) : $content .= apply_filters('archive_meta', category_description()); endif;
    $content .= '</div>';
    }
    return $content;
    }
    add_filter('thematic_page_title', 'child_page_title');

    ?>

    BTW, is it necessary (for SEO purposes) to have "Category Archives:" in the page title and category page titles? Thanks!

    Posted 4 years ago #
  5. Needless to say that the above code is sloppy and any help would be appreciated; i.e. the h1 and span tags drop out when it prints to page.

    Thanks again.

    Posted 4 years ago #
  6. Hullo whatsthebigidea-

    The span and h1's are missing because you're overwriting the value of $content when you need to be concatenating it. All but the first instance of $content = need to be changed to $content .=

    -Gene

    Posted 4 years ago #
  7. Thanks em hr! I added the "." for concatenating and the resulting html is this:

    <div id="content">
    Get Involved
    <h1 class="page-title">
    <span/>
    </h1>
    <p>Get involved with ways to Support Saugerties for Smart Development including letter writing, social networking, donations, contributions and volunteering.</p>
    </div>

    The "Get Involved" should be within the h1 tags. Any tips?

    Posted 4 years ago #
  8. berty7386
    Member

    tanx for the information

    Posted 4 years ago #
  9. Hi whatsthebigidea -

    Try changing TRUE to FALSE :

    $content .= single_cat_title('', FALSE);

    With single_cat_title setting the $display parameter to TRUE will make the function echo the results which in turn displays it's value before the filter is returned.

    -Gene

    Posted 4 years ago #
  10. I'm not sure whether @whatsthebigidea ever solved his problem but I find this code works for filtering the page title - its copied from the content_extensions.php:

    function your_page_title_filter() {
    		global $post;
    		$content = ''; //MAKE SURE YOU DEFINE THIS AS EMPTY HERE
    
    		if (is_category()) {
    				$content .= '<h1 class="page-title">'; //BEGIN CODE HERE
    				$content .= __('', 'thematic');
    				$content .= ' <span>';
    				$content .= single_cat_title('', FALSE);
    				$content .= '</span></h1>' . "\n";
    				$content .= '<div class="archive-meta">';
    				if ( !(''== category_description()) ) : $content .= apply_filters('archive_meta', category_description()); endif;
    				$content .= '</div>';
    
    	} 
    
    			return $content;
    	}
    
    add_filter('thematic_page_title', 'your_page_title_filter');

    Posted 4 years ago #
  11. missed an open bracket ( on the add_filter but you get the picture!

    Posted 4 years ago #
  12. Thanks guys! Unfortunately, the resulting code leaves the page with an open h1 tag: http://www.rsci.com/tools-hand-power. At the same time, archerjd fixed an open div tag.

    Posted 3 years ago #
  13. Hi,

    I'm not sure why you're getting the open H1. archerjd's way would have worked on the category page but removed the page title in all other instances. You need to return the original functions data if the condition of your filter is not met.

    Try this:

    function your_page_title_filter($content) {
    		if (is_category()) {
    				$content  = '<h1 class="page-title">';
    				$content .= __('', 'thematic');
    				$content .= ' <span>';
    				$content .= single_cat_title('', FALSE);
    				$content .= '</span></h1>' . "\n";
    				$content .= '<div class="archive-meta">';
    				if ( !(''== category_description()) ) : $content .= apply_filters('archive_meta', category_description()); endif;
    				$content .= '</div>';
    		}
    			return $content;
    	}
    add_filter('thematic_page_title', 'your_page_title_filter');

    As a side note: The period at the end of the sentence inside your anchor tag the link leads to a 404 where you have two search inputs I'm assuming you intended to have only one search on that page.

    Posted 3 years ago #
  14. Jamie Mitchell
    Member

    hi all...

    how can i filter the index title

    i want to add a little arrow like Ian has on http://wpazo.com/

    Posted 3 years ago #
  15. Robo
    Member

    Hi everyone, any idea how to filter the_tags to remove or limit the number of tags displayed after a post.

    Posted 3 years ago #
  16. Thank you! This is exactly what I was looking for!

    -Jay

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.