Updated theme, and it's calling the deprecated post_class()

Home Forums Using Thematic Child Themes Build Your Own Custom Child Themes Updated theme, and it's calling the deprecated post_class()

This topic is: not resolved

This topic contains 9 replies, has 3 voices, and was last updated by  lucaska 4 years, 2 months ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #3761

    lucaska
    Participant

    So I inherited a project where the theme is a child of thematic. They updated the theme, and now above most of the posts we get:

    Warning: Missing argument 1 for thematic_post_class(), called in /home/smmoadev/public_html/wp-content/themes/smmoa/two-columns-with-sidebar.php on line 15 and defined in /home/smmoadev/public_html/wp-content/themes/thematic/library/extensions/dynamic-classes.php on line 402

    I saw that the thematic_post_class() has been deprecated, and I added the legacy support to my functions.php, but that doesn’t change it.

     

    If I change thematic_post_class(), to post_class(), in two-columns-with-sidebar.php in the child theme, I get a different error, with metadata showing up where the error was.

    I need some help with this issue, as I know nothing about how Thematic works, and I’d like to clear this up before I start actually digging.

     

    Thanks in advance for any advice.

     

    -Lucas

    #3766

    Scott Nix
    Moderator

    The process “If I change thematic_post_class(), to post_class()” you mentioned is exactly the correct way to fix this issue.

    You mentioned though you get a different error with metadata that show up. This is a little confusing, if you could provide more information it would be easier to help. Possibly pasting that template into http://hastebin.com/ so the error can be reproduced.

    #3785

    lucaska
    Participant

    If I do the fix above, instead of  the error showing at the top of the body, it shows

     

    class=”post-55 page type-page status-publish hentry p publish author- untagged comments-open pings-open y2012 m05 d17 h07 alt slug-hours-admission”

     

    And when inspecting that, it shows that for some reason it is printing it’s corresponding class into the body?

     

    https://gist.github.com/LucasKA/37e5bec88bb298cce690

    #3786

    lucaska
    Participant

    Something in the theme is injecting that text right outside the  opening <body> tag, and I can’t figure out what is doing it.

    #3787

    lucaska
    Participant

    It seems to me it’s still connected to those deprecated classes.

    I pulled out

    
    add_theme_support('thematic_legacy_body_class');
    
    add_theme_support('thematic_legacy_post_class');

    And it reduced the text to just

    class=”post-55 page type-page status-publish hentry”

    I apologize for all the posts, but I like to not only talk “out loud” because it helps me figure it out, it might help you figure out what I am talking about.

    #3789

    Scott Nix
    Moderator

    I am can’t 100% test it because it calls some dependencies, but.

     

    Possibly try commenting this out

    if (!(THEMATIC_COMPATIBLE_POST_CLASS)) {
    $div_class = get_post_class();
    } else {
    $div_class = post_class();
    }

    and swapping out the $div_class to use $post_class that is called in the actual div in the code on line 52 of your gist.

    #3792

    lucaska
    Participant

    Thanks for the attempt, but that didn’t do it.

     

    If you have any other suggestions, please let me know, this is on a production site, and I gotta get it fixed.

    You can see it at the top here

    http://smmoa.org/visit/hours-admission/

     

    The thing that is messed up, is that if you inspect it, its just

    “class=”post-55 page type-page status-publish hentry””

    plopped into the body somehow.

     

     

    #3793

    lucaska
    Participant

    Here’s some interesting info:

    The only pages this is happening on, is ones that are using the redirect to first child.

    So that link I gave would be ?page_id=55?page_id=27, and whatever code is injecting that into the body is because of that parent page.

    But does anyone know WHAT CODE is doing this?

    #3794

    middlesister
    Keymaster

    If my suspicion is correct, the only pages where this happens are the pages that uses your page templates similar to that gist.

    Here’s the thing: the post_class() function is a function that echoes/prints the info directly to the page. Since there is a call to that function even before get_header() then the post class string is output then and there, before everything else. This is why Scott suggested to comment out that part of the code. The result of the post_class() function cannot be stored in a variable.

    Try changing line 52 to

    <div id="post-<?php the_ID(); ?>&#8221; <?php post_class(); ?> > 

    and remove or comment out all references to post_class() before that. This will echo exactly the same as what you have in your template, but without using variables. Do this in every custom page template you have. The front page template seems to be two-columns-with-sidebar.php (taken from the body classes).

    #3800

    lucaska
    Participant

    That did it!

     

    I tried that earlier, but what I had done was actually replace

    if (!(THEMATIC_COMPATIBLE_POST_CLASS)) {
    $div_class = get_post_class();
    } else {
    $div_class = thematic_post_class();
    }

    with

    $div_class = post_class();

    Not realizing it was THAT which was injecting the post class into the body.

     

    Many thanks! I’m glad its solved, I didn’t want to have to roll back to version 0.97 or whatever it was running.

Viewing 10 posts - 1 through 10 (of 10 total)

The topic ‘Updated theme, and it's calling the deprecated post_class()’ is closed to new replies.