views:

47

answers:

2

I have a site whose home page shows a single Wordpress category page. I'm using a custom theme and the index.php file there does a 301 redirect to "mysitename.com/?cat=3". This page is generated with an event calendar plugin and a lot of custom code. It works, but the displayed URL is "mysitename.com/?cat=3" which I'd prefer my visitors not see; I'd rather have the URL be just "mysitename.com", "mysitename.com/index.php", or even "mysitename.com/calendar".

The visitor can view "prev month" and "next month", which result in URLs like "mysitename.com?cat=3&eventDate=2010-07&bt=a" -- still within the same category but with additional parameters in the URL. (I am OK having a more convoluted URL like this shown to my visitors on previous/next month; it's just the initial page URL I'd like to be nicer.)

I've messed around with the permalinks but can't get nice URLs to work correctly that way. Is there an .htaccess way to do this?

A: 

In the "permalinks" section under the "Settings" tab, you can add a category base to the categories.

Thus if you have a category base of "category" and a category name "Cool Stuff" with a slug of "cool_stuff"

Your category link would link like this depending on your permalink settings.

http://yoursite.com/category/cool_stuff/


Okay. My Last answer was not base on your "edited question".

If you remove the 301 redirect to "mysitename.com/?cat=3" you can edit the index.php file.

This will most likely take care of your url issue.

You can edit the loop to show only categories from id: 3

Thus, you will make a querypost for category 3 as follow:

<?php query_posts('showposts=9'); ?>

See Query Post @ Wordpress for more info.

Put this before the loop.

The coding may look like this:

<?php query_posts('cat=3'); ?>
<?php if (have_posts()) {?>
    <?php while (have_posts()) : the_post(); ?>
        <li>
            <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
            <span style="float: right;"><?php the_time('m/d/y'); ?></span>
        </li>
<?php endwhile; }?>
Anraiki
(I'm the OP) Close, but still not working the way I need it to. Removing the 301 redir and adding the query_posts() code *does* show me just that category at "mywebsite.com". But it's showing a post within that category, rather than the calendar. I didn't write the plugin or do the customization, but I *think* it's "riding on" a category post to get rendered but isn't behaving like a normal WP post. I see the plugin calling a PHP class that, in turn, references a PHP file that's got the actual xHTML code to render. So I'm wondering again if perhaps an .htaccess solution is better?
A: 

You could use .htaccess to map mywebsite.com/calendar to mywebsite/?cat=3, but WordPress will still look at the original url to find out which category to use, so this will not work.

I suggest you look in the code of the plugin to find out how it gets the current category, and maybe trick it (by an extra call to query_posts('cat=3')) to think we are looking at the url for category 3 (you don't need to display the posts, just do the query). You can even do this on your homepage (but maybe use home.php, not index.php, since the latter is a fallback for other template pages), so you don't need a redirect. But the key is that you need to look at the code of your plugin (can you tell us the name?) to find out how it works.

Jan Fabry
Sorry, I misunderstood the OP. Just reread and deleted my original comment.
qmega