WordPress.org

Ready to get started?Download WordPress

Forums

Category Template Hierarchy
[resolved] Cannot use $post->post_content with this plugin (4 posts)

  1. clinton4
    Member
    Posted 2 years ago #

    Hi,

    When i use this plugin, i cannot use $post->post_content in my template.

    example, it is not working in child-of-category-{slug}.php

    Any idea on how to resolve this?

    http://wordpress.org/extend/plugins/category-template-hierarchy/

  2. Eddie Moya
    Member
    Plugin Author

    Posted 2 years ago #

    You are the second person to report a similar problem, the strange part is that I seem incapable of reproducing it. What version of WordPress are you running on, and are you doing anything else custom with template redirection, or with the loop in general?

    For the mean time, declaring global $post; at the top of your template should fix the problem until I find the cause.

    As an aside, why do you use $post->post_content instead of using the_content() or get_the_content()? If for some odd reason you dont have access to the_content() function that might help explain why you and this other individial are having such a strange problem.

    Sorry for answering this so slowly, I was under the mistaken impression that you where the same individual who asked reported this on my blog.

    Thanks for reporting this.

  3. Eddie Moya
    Member
    Plugin Author

    Posted 2 years ago #

    I have found the problem. Monday morning I will release 1.2.1 which should resolve the issue.

    The reason I was not seeing this bug is because I was using get_template_part(), which itself brings $post in from the global scope. This problem is occurring in the first place because I switched from filtering all of 'template_redirect' (which broke other parts of the template structure) to filtering just 'category_template' - but didn't realize the impact it had on the global scope variables.

    In any case, thanks for the bug report, check back monday for the update.

  4. Eddie Moya
    Member
    Plugin Author

    Posted 2 years ago #

    I've updated the plugin to version 1.3 - please update your copy to resolve the problem.

    Please let me know if you have any further issues.

    Thanks again.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic