ThemeShaper Forums » Thematic

[closed]

How do I reorganise the HTML for post meta info?

(10 posts)
  • Started 13 years ago by Foomandoonian
  • Latest reply from Foomandoonian
  • This topic is resolved

Tags:

  1. Thanks to helgatheviking I've learned how to move bits from the extensions library into functions.php to tweak under the hood, despite my complete lack of PHP-fu. I've come unstuck with my attempts to reorganise the post meta section though. Here's how I want the HTML to look:

    span class="comments-link" a href="#" 0 Comments /a /span 
    
    ul class="cat-links"
    li a href="#"Category link /a /li
    li a href="#"Category link /a /li
    /ul
    
    ul class="tag-links"
    li a href="#" class="tag-name" Tag link /a /li
    li a href="#" class="tag-name" Tag link /a /li
    /ul
    
    span class="edit" a href="#" Edit /a /span

    From content-extensions.php, I'm looking at extracts like this:

    // Create post category
    function childtheme_override_postfooter_postcategory() {
    
    	    $postcategory = '<span class="cat-links">';
    	    if (is_single()) {
    	        $postcategory .= __('This entry was posted in ', 'thematic') . get_the_category_list(', ');
    	        $postcategory .= '</span>';
    	    } elseif ( is_category() && $cats_meow = thematic_cats_meow(', ') ) { /* Returns categories other than the one queried */
    	        $postcategory .= __('Also posted in ', 'thematic') . $cats_meow;
    	        $postcategory .= '</span> <span class="meta-sep meta-sep-tag-links">|</span>';
    	    } else {
    	        $postcategory .= __('Posted in ', 'thematic') . get_the_category_list(', ');
    	        $postcategory .= '</span> <span class="meta-sep meta-sep-tag-links">|</span>';
    	    }
    	    return apply_filters('thematic_postfooter_postcategory',$postcategory); 
    
    	} // end postfooter_postcategory

    I simply don't understand what's going on with the .= or the period separators or what the 'thematic' in __('Posted in', 'thematic') does (or $cats_meow!!!).

    It would be fantastic if someone could give me a basic template for how to edit this category section to produce the lists I need, or give me a pointer in that direction.

    ALSO, I'd like to put, if possible, the URL-friendly slug for my tag names into the anchors as a class so I can style them individually. If possible. This isn't critical, but would be a nice touch.

    Any help much appreciated!

    EDIT: Despite not using angle brackets, my HTML sample still broke the page. I hope it's still clear.

    Posted 13 years ago #
  2. to clear up some of your questions:

    "I simply don't understand what's going on with the .= "

    in PHP .= means "add this to the end of whatever you have for the variable. so basically thematic is defining the $output variable and is just tacking stuff on to the end each time it says $output .=

    so

    $output = "We Like"
    $output .= " bacon"
    
    echo $output;
    
    //will produce:
    //We Like bacon

    "what the 'thematic' in __('Posted in', 'thematic') does"

    while i am not 100% sure i know that it has to do with translation.

    `
    __('Something') returns a translatable string
    _e('Something') echos a translatable string

    the second value, i believe, identifies it as a tag that needs to be translated if you are translating thematic.

    " (or $cats_meow!!!)."

    the cats_meow function is a clever bit o' php that gets the category list, but if you are on a category archive it will EXCLUDE that category list so that, for instance, a post was in categories A, B and C. and you were on the archive page for category C... your meta would read

    Also posted in A, B

    and not: Also posted in A,B,C

    b/c the C part is sort of obvious since you are on the C category page

    hope that helps.

    btw- adding unique classes to the tags... don't know how to do that. but i suspect it would have to be in filtering

    get_the_category_list or get_the_tag_list (does that 2nd one exist? not sure but there must be a tag version of the former)

    Posted 13 years ago #
  3. Thanks to you once again! I think I know enough to carry on. I'll mark this post as resolved if I get it done. :)

    We do like bacon.

    Posted 13 years ago #
  4. ain't nothin' wrong w/ a little bacon. ;)

    Posted 13 years ago #
  5. I've ended up with the following:

    function childtheme_override_postfooter_postcategory() {
      $postcategory = '<ul class="cat-links">';
      $postcategory .= 'li' . get_the_category_list() . '/li';
      $postcategory .= '</ul>';
    return apply_filters('thematic_postfooter_postcategory',$postcategory);
    }

    Much simplified, though I realise I've ejected some good functionality. It works on my page, so I'm going to mark this post as resolved - but please let me know if you see any potential problems.

    And thanks once more for the support. :)

    EDIT: I think this forum has a thing against lists. I've edited my extract above to remove some < and >'s.

    Posted 13 years ago #
  6. do you need that wrapping <li></li> ?

    Posted 13 years ago #
  7. Oh yeah, you're absolutely right! I hadn't realised that get_the_category_list() contained that markup also. Now I have the even simpler:

    function childtheme_override_postfooter_postcategory() {
    $postcategory = get_the_category_list();
    return apply_filters('thematic_postfooter_postcategory',$postcategory);
    }

    I guess I'll try the tags now, as I have a hunch that I won't just be able to throw get_the_tag_list into a class attribute...

    Thx again!

    Posted 13 years ago #
  8. How do I override stuff like the 'Read more' text, or the text that appears in the search box? content-extensions.php has the following, but I can't move this to my functions.php in the same way...

    // creates the $more_link_text for the_content
    function more_text() {
    $content = ''.__('Read more <span class="meta-nav">»</span>', 'thematic').'';
    return apply_filters('more_text', $content);
    } // end more_text

    Or am I missing something?

    Posted 13 years ago #
  9. yeah you are missing the other half of the thematic brilliance equation: filters

    http://themeshaper.com/filters-wordpress-child-themes/

    function child_more_text(){
         $content = "bacon everywhere!";
    }
    add_filter('more_text','child_more_text');
    Posted 13 years ago #
  10. I think I can see what that's doing, but when I try it actually replaces 'Read more ยป' with '(More...)', and not the text I specify. Though the hover styling does look a little like a strip of bacon.

    Still struggling with tags too. I'm so close now!

    Posted 13 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.