• I am using show_categories written by MooKitty. I change my $cat dynamically using static links located in a navigation bar. If someone clicks on reviews and the cat_id = 5 then the link is:
    /index.php?cat=5
    and only reviews will show up. This gives the semi-static illusion.
    The problem is that if the $cat is empty I assume the user was hitting the site for the first time and set it to 1. Like this:
    if (empty($cat)){ $cat = 1;}
    The problem is that Permalinks and Calendar links don’t pass the cat_id. They only pass the post_id. It breaks want I was trying to do. My code sets the $cat to 1 whenever a permalink or Cal link is clicked.
    Any ideas how to get around this? I know I have to hack something and it would be great if a developer would chime in. I don’t know the whole framework yet.
    Thanks in advance for any suggestions
    -Ken
    BTW: please don’t tell me to post a URL because if you know PHP and WP I shouldn’t have to. I have posted enough info to explain the issue. Posting a URL is only going to show you the HTML.

Viewing 2 replies - 1 through 2 (of 2 total)
  • What about a URL?
    Kidding!
    Try the following:
    if (empty($_SERVER['QUERY_STRING'])) {
    $cat = "1";
    }

    This will verify no query string is being passed. Hence, they’re on the home page.

    Thread Starter kvillines

    (@kvillines)

    That does the trick for the homepage problem. Thanks
    I still have the problem of the permalinks, Cal links, and even the More… link only passing the post_id like this:
    index.php?p=5#more-5
    If I manually add the cat like this:
    index.php?p=5#more-5&cat=5
    then it works… My code is doing something like this:
    if (empty($_SERVER['QUERY_STRING'])) { $cat = 1;}
    $cat_title = show_category_posts('category='.$cat);
    switch ($cat) {
    case 1:
    $home = "images/home_over.jpg";
    $home_scrub = "images/home_scrub_over.gif";
    $cat_value = 1;
    break;
    case 14:
    $event = "images/events_over.jpg";
    $event_scrub = "images/events_scrub_over.gif";
    $cat_value = 2;
    break;
    case 2:
    case 3:
    case 4:
    case 5:
    $rsc = "images/rsc_over.jpg";
    $rsc_scrub = "images/rsc_scrub_over.gif";
    $cat_value = 3;
    break;
    case 7:
    case 8:
    case 9:
    case 10:
    $theater = "images/theater_over.jpg";
    $theater_scrub = "images/theater_scrub_over.gif";
    $cat_value = 4;
    break;
    case 15:
    $store = "images/store_over.jpg";
    $store_scrub = "images/store_scrub_over.gif";
    $cat_value = 5;
    break;
    case 6:
    $contact = "images/contact_over.jpg";
    $contact_scrub = "images/contact_scrub_over.gif";
    $cat_value = 6;
    break;
    case 11:
    $about = "images/about_over.jpg";
    $about_scrub = "images/about_scrub_over.gif";
    $cat_value = 7;
    break;
    }

    show_category_posts() sets the global $scp_posts. The other section of the code looks like this:
    <?php echo '<h4>'.$cat_title.'</h4>';
    if ($scp_posts) : foreach ($scp_posts as $post) : start_wp(); ?>
    <?php the_date('','<h2>Posted: ','</h2>'); ?>
    <div class="newsbody">
    <h1>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></h1>
    <div class="meta"><?php _e("Filed under:"); ?> <?php the_category() ?> — <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(); ?></div>
    <?php the_content(); ?>
    <div class="feedback">
    <?php wp_link_pages(); ?>
    <?php comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)')); ?>
    </div>
    <?php include(ABSPATH . 'wp-comments.php'); ?>
    </div> <!-- end news div -->
    <?php endforeach; else: ?>
    <div class="newsbody">
    <?php _e('Sorry, no posts matched your criteria.'); ?>
    </div> <!-- end news div -->
    <?php endif; ?>

    If $cat is not set by anything then show_category_posts() doesn’t work at all. Any ideas are appreciated.
    Thanks
    -Ken

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘$cat and permalink issues’ is closed to new replies.