Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter hedgomatic

    (@hedgomatic)

    dashes didn’t seem to work either until I realized I shouldn’t use an alternate name for the slug.

    Naming my slug “Volume1-Issue3”

    and then doing:

    query_posts(‘category_name=Volume1-Issue3’);

    works.

    Thread Starter hedgomatic

    (@hedgomatic)

    after looking at bug 11121, I gathered that sanitize_title() in formating.php is responsible for cleaning the category names.

    Nothing I saw there or in apply_filters() would create the issue however. I’ve no mind to edit the core of course, but it’d be nice to know if there’s a possible override for this.

    Thread Starter hedgomatic

    (@hedgomatic)

    Fixed:

    While I was indeed confused on what is_category() does, I did manage to figure out that the problem is a bug and/or limitation in WordPress: it doesn’t accept underscore (_) characters in category names.

    Thread Starter hedgomatic

    (@hedgomatic)

    here’s a screeshot of the post that should be pulled by the logic above.

    Here’s the relevant code all in one chunk:

    <?php
    if (current_user_can('manage_options')) {
    	$is_admin = true;
    	$Volume = get_option( $opt_nextVolume_name );
    	$Issue = get_option( $opt_nextIssue_name );
    	$VolumeAndIssue = 'Volume'.$Volume.'_Issue'.$Issue;
    	if (is_home()) { query_posts('category_name='.$VolumeAndIssue); } else { query_posts('category_name=Live'); }
    } else {
    // not logged in query, etc
    }
    if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    		<? /*** CUSTOM THEME OPTIONS FOR THE ISSUE ***/ ?>
    		<?php include(TEMPLATEPATH.'/'.$VolumeAndIssue.'.php'); ?>
    		<?php the_content(__('(more...)')); ?>
    <?php endwhile; else: ?>
    	<p><?php _e("Sorry, we couldn't find what you were looking for."); ?></p>
    <?php endif; ?>

    Returns:

    “Sorry, we couldn’t find what you were looking for.”

    Update: If I remove the query_post(), thereby getting all my published posts, and then try:

    <? if(is_category($VolumeAndIssue)) { echo 'test'; } ?>

    returns nothing. So for some reason it considers the post not to be assigned to this category. The plot thins.

    Running get_the_category has gotten me really stumped. Consider this:

    <?php
    echo '<b>Categories: </b>';
    foreach((get_the_category()) as $category) {
        echo $category->cat_name . ' ';
    }
    echo '<BR /><B>VolumeAndIssue variable:</b> '.$VolumeAndIssue;
    ?>

    returns this.

    I then removed the ‘offline’ tag, just in case there was an issue with that being the first category. No change.

    Update 2:

    Something’s not right here.

    foreach((get_the_category()) as $category) {
        echo $category->cat_name . ' ';
    if(is_category($category->cat_name)) { echo '<br />debug:'.$category->cat_name.'<br />'; }	else { echo '<br />can\'t find category<br />'; }
    }

    Unless I’m confused as to how this conditional works, it should always be able to find the category. However it returns false having not found the category it just found. Huh?!?

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