Forum Replies Created

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter danharper

    (@danharper)

    oh yea – I want to wade through one giant file to modify stuff – not
    wp uses a simple hierarchy that is easy to work with
    Ruby on Rails is a huge pain in the butt
    my .02

    How so? This file only contains the code for displaying a post. Everything else is handled inside their relevant files.

    Obviously, if your posts are drastically different between pages (eg. how you display a post in index is completely different to how it looks in archive) then it makes sense not to do it this way.
    But I’d guess the vast majority of templates contain the same post layout throughout.

    The only normal differences would be:

    • Content vs Excerpt
    • Linked Title vs Plain Text
    • Displaying category & comment count (if using the partial for a page.)

    and all these can be handled with a simple ‘if is_single’, ‘if is_post’.

    Personally, I’d much rather have one file containing my post layout than have the exact same code in a bunch of files.

    Thanks for the quick response πŸ™‚

    Thank-you Michael.

    Also, I’ve tried this on a fresh install of 2.8, no plugins installed, and using the default theme.

    Michael, in your example, you are creating a function in functions.php which calls get_categories(), but you use that function in a front-end file.

    Our problem is that get_categories() does not work when used solely in the back-end – ie. we’re creating a options page for our theme which requires a list of the categories.

    Try out my example, and you’ll see it does not work.

    Michael, I posted this just in another thread, so sorry for double-posting:

    This is definitely either an undocumented feature change or a bug in WP 2.8 as the get_categories() function can not retrieve any categories when used inside functions.php – anywhere on the front-end is fine.

    To test this, include the following code to the very top of a functions.php file:

    echo '<pre>';
    print_r(get_categories('hide_empty=0'));
    echo '</pre>';

    Now, as you know, this should print out an array containing all categories on the site.
    Try this on 2.7.1 and all other older versions, the code works correctly by printing out:

    Array
    (
        [0] => stdClass Object
            (
                [term_id] => 3
                [name] => Tutorials
                [slug] => tutorials
                [term_group] => 0
                [term_taxonomy_id] => 3
                [taxonomy] => category
                [description] =>
                [parent] => 0
                [count] => 5
                [cat_ID] => 3
                [category_count] => 5
                [category_description] =>
                [cat_name] => Tutorials
                [category_nicename] => tutorials
                [category_parent] => 0
            )
    ....
    ....
    )

    However in 2.8, the following is output:

    Array
    (
        [errors] => Array
            (
                [invalid_taxonomy] => Array
                    (
                        [0] => Invalid Taxonomy
                    )
    
            )
    
        [error_data] => Array
            (
            )
    
    )

    As I stated, the code works fine in front-end files, but not in the back-end.

    This is not a problem with a theme or plugin error, as exactly the same problem is seen if you add the code to the default WordPress themes.

    This is definitely either an undocumented feature change or a bug in WP 2.8 as the get_categories() function can not retrieve any categories when used inside functions.php – anywhere on the front-end is fine.

    To test this, include the following code to the very top of a functions.php file:

    echo '<pre>';
    print_r(get_categories('hide_empty=0'));
    echo '</pre>';

    Now, as you know, this should print out an array containing all categories on the site.
    Try this on 2.7.1 and all other older versions, the code works correctly by printing out:

    Array
    (
        [0] => stdClass Object
            (
                [term_id] => 3
                [name] => Tutorials
                [slug] => tutorials
                [term_group] => 0
                [term_taxonomy_id] => 3
                [taxonomy] => category
                [description] =>
                [parent] => 0
                [count] => 5
                [cat_ID] => 3
                [category_count] => 5
                [category_description] =>
                [cat_name] => Tutorials
                [category_nicename] => tutorials
                [category_parent] => 0
            )
    ....
    ....
    )

    However in 2.8, the following is output:

    Array
    (
        [errors] => Array
            (
                [invalid_taxonomy] => Array
                    (
                        [0] => Invalid Taxonomy
                    )
    
            )
    
        [error_data] => Array
            (
            )
    
    )

    As I stated, the code works fine in front-end files, but not in the back-end.

    This is not a problem with a theme or plugin error, as exactly the same problem is seen if you add the code to the default WordPress themes.

    Thread Starter danharper

    (@danharper)

    Hey, sorry for the double-post; but I really need help with this! If someone can help, it’d be greatly appreciated.

    The only thing I can think of, is that I’m running the site on a Windows test server; but unless Apache/SQL on Windows somehow interprets things differently, that’s just stupid!

    Thanks.

    Thread Starter danharper

    (@danharper)

    No, that doesn’t work. BTW, when I put orderby=post_date, I meant to put orderby_date.

    I’ve also tried
    query_posts(array('category__not_in'=>array(7),'showposts'=>10,'orderby'=>'date','order'=>DESC));
    Which is code I got from the Codex, and isn’t working.

Viewing 9 replies - 1 through 9 (of 9 total)