WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Trouble calling up title/category in 1.3a4 (5 posts)

  1. Kafkaesqui

    Posted 9 years ago #

    I'm having a real headache. Using 1.3 alpha-4 (Oct-25 build).
    I'm assigning the title of an article (on a single entry page) to a variable outside the loop. Using get_the_title($post)worked fine in 1.2, but in 1.3 fails to return a value. As single_post_title('', FALSE) provides the same functionality, no big deal (for me) here.
    I'm doing the same thing with a category (on category page). Again, get_the_category_by_ID($cat) worked in 1.2 but not 1.3. Well, that's not quite correct. It does works in 1.3, but only for one of two installations I'm running. Also, single_cat_title('', FALSE)fails, but again only for one of the two.
    Again, they're both running the same 1.3 alpha (and same versions of PHP and MySQL, such as it relates). The only real differences I know of between my 1.3 installs are:
    1. Server of version that works is running IIS, one that doesn't is Apache.
    2. Version that works is in root folder, one that doesn't is in a subdirectory.

  2. Kafkaesqui

    Posted 9 years ago #

    Ok, thought of one more difference, which points at something:
    I'm using custom permalinks on the site where both category functions fail. Just tested and yes both get_the_category_by_ID() and single_cat_title() pass the right value if I use the cruft link to that page. However, in a setup of 1.2 and custom folders, I don't have this problem.

  3. Ryan Boren
    WordPress Dev
    Posted 9 years ago #

    I just made a fix to wp-blog-header which should fix get_the_category_by_ID($cat). I'm not sure what is wrong with single_cat_title(). It works fine for me when using permalinks. Make sure your copy of single_cat_title() contains a call to get_query_var('cat').
    get_the_title() has never accepted an argument. Although, if you assign to the $post global before calling it, it should work. I'll investigate.

  4. Kafkaesqui

    Posted 9 years ago #

    Make sure your copy of single_cat_title() contains a call to get_query_var('cat').

    Yep, it's there.
    I've done some further work and found I can (finally!) get things to run as expected, but I have to change how I'm verifying the type of page I'm on. Typically I perform a simple:
    if( !empty($cat) )
    For some reason this was not working (that is, for 1.3 and custom permalinks). However, this works fine (though it does look a little strange):
    if( single_cat_title('', FALSE) )

    get_the_title() has never accepted an argument.

    Can't say where I picked it from, then. Probably assumed it was required when I set up the script (trial and error, you know...).
    Thanks for looking into this.

  5. Ryan Boren
    WordPress Dev
    Posted 9 years ago #

    $cat should be set correctly with my change. If you want to know if you're on a category page, you can do if ( is_category() ).

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.