Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter maf5995r

    (@maf5995r)

    I’ve created a work around for myself and I believe the problem is different than my initial suspicion.

    Ticket http://trac.wordpress.org/ticket/1199 appears to be the bug I’ve encountered.

    Here’s a summary:

    When I create a custom structure for permalinks in the Options>Permalinks panel as:

    /%category%/%postname%/

    the generated permalink using the get_permalink() function does not include the %category% field.

    For example, the incorrectly generated permalink is http://www.example.com//my-first-post/ for a post named “My First Post” in the “Website” category.

    Initially, I considered this might be a permalink generation with %category% and Apache 1.x problem. See http://wordpress.org/support/topic/90171.

    After working through some of the WordPress code, I believed it to be related to the WordPress 2.0+ caching problem mentioned elsewhere.
    See http://trac.wordpress.org/ticket/1199 and http://wordpress.org/support/topic/55472.

    However, disabling the cache through uncommenting define(‘DISABLE_CACHE’, true) in wp-settings.php did not fix my problem.
    Additionally, there is no wp-contents/cache directory in my installation and the webserver does not have write permission in my httpdocs directory.

    My configuration includes WordPress 2.0.4, Apache/1.3.27, PHP/4.2.2.

    My observations included that in template-function-links.php, at line 55-61:

    $category = ”;
    if ( strstr($permalink, ‘%category%’) ) {
    $cats = get_the_category($post->ID);
    $category = $cats[0]->category_nicename;
    if ( $parent=$cats[0]->category_parent )
    $category = get_category_parents($parent, FALSE, ‘/’, TRUE) . $category;
    }

    get_the_category indeed returns an array with a single element, but there is no set category_nicename (nor cat_ID nor cat_name) for that element.

    I added a few links of code to re-query the WordPress database when $category was not set as expected and this worked for me. Note, I know my installation contains a non-hierarchical set of categories and that only category is assigned to a single post and I did not work through a more general “fix”.

    $category = ”;
    if ( strstr($permalink, ‘%category%’) ) {
    $cats = get_the_category($post->ID);
    $category = $cats[0]->category_nicename;
    if (!isset($category)) {
    global $wpdb;
    $dogs = $wpdb->get_results(“SELECT post_id, category_id FROM $wpdb->post2cat WHERE post_id=$post->ID;”);
    $category_object = &get_category($dogs[0]->category_id);
    $category = $category_object->category_nicename;
    }
    if ( $parent=$cats[0]->category_parent )
    $category = get_category_parents($parent, FALSE, ‘/’, TRUE) . $category;
    }

    — Mark
    MAFAdmin@gmail.com

    Thread Starter maf5995r

    (@maf5995r)

    Digging a bit deeper…

    In template-function-links.php, at line 55-61:

    $category = ”;
    if ( strstr($permalink, ‘%category%’) ) {
    $cats = get_the_category($post->ID);
    $category = $cats[0]->category_nicename;
    if ( $parent=$cats[0]->category_parent )
    $category = get_category_parents($parent, FALSE, ‘/’, TRUE) . $category;
    }

    get_the_category indeed returns an array with a single element, but there is no set category_nicename (nor cat_ID nor cat_name) for that element.

    I’m wondering if this is the Apache problem or some other problem?

    Thanks,

    — Mark

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