WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to rewrite Category Permalink Structure (37 posts)

  1. CapeCodBranding
    Member
    Posted 5 years ago #

    I currently use the permalink structure 'Day & Name" and I love it b/c it is very easy to 'see' what page you are on in my blog. I'd like to keep using that structure for my links. The problem is that Categories don't work on my site. No matter which Category widget I use, it just yields a blank page (with header but no content). However, Categories do work if I use the Default Permalink structure.
    My category link structure is currently redirecting to this;

    http://capecodbranding.com/blog/category/how-to/

    How can I alter this so categories work? I noticed in "Control Panel > Settings > Permalinks" there is a place to override just the categories (or tags) link structure and I've been playing around but can't find a solution that works.

    Any help would be appreciated!
    Thanks,
    amy

  2. joshmac
    Member
    Posted 5 years ago #

    From what I can see your link structure is like so http://capecodbranding.com/blog/posts/category/psychology/ which will then redirect you to the correct page. So /blog/ is the root, but not sure where /posts/ comes into the picture. Usually, if /blog/ is the root, your categories should come out /blog/category/psychology/. Just throwing this out so that you can figure out how /posts/ comes up in your url structure.

  3. CapeCodBranding
    Member
    Posted 5 years ago #

    Hi Parkstreet!

    Ok, so you made it farther than I did. I'm not sure how you found the link structure you did, but it goes where I want it to go...

    I'm not sure about the 'posts' part either (I'm very new to the permalink aspect of wordpress, I've never had to look at it before now).

    When I click on a category from my sidebar Cloud I get the permalink that I copied into my post above;

    http://capecodbranding.com/blog/category/apple/

    and it goes to a blank screen. Do you know how I can get my category widget to direct to the url that you found?

    Thanks!
    amy

  4. iridiax
    Member
    Posted 5 years ago #

    Your category archives are generating 500 Internal Server Errors. Make sure that the Category base is blank in your permalink settings, remove any category-specific rewrites you may have added to your .htaccess, and disable any rewrite or category-related plugins.

  5. joshmac
    Member
    Posted 5 years ago #

    I echo what @iridiax states above.

  6. CapeCodBranding
    Member
    Posted 5 years ago #

    Hi iridiax,

    I have deleted the one category widget I was using (WP-Cumulus), I don't have anything in the Category base in the permalink settings and the only thing I have ever added to my .htaccess is a 301 redirect.
    I enabled the standard category widget that came with WP so I can still test my categories.
    When I click on one of my categories I'm still getting a blank white page (that has my header logo on it). Do you still see an Internal Errors message?

    Thanks for the help,
    amy

  7. iridiax
    Member
    Posted 5 years ago #

    the only thing I have ever added to my .htaccess is a 301 redirect.

    Try removing it. Set your permalinks to default. Rename your .htaccess (to disable it) and then regenerate your Day & Name permalinks to generate a fresh new .htaccess. Also check your root .htaccess for something that could be messing things up.

  8. iridiax
    Member
    Posted 5 years ago #

    500 Internal Server Errors are often caused by problems with a .htaccess file. Your category archives are still showing them.

  9. joshmac
    Member
    Posted 5 years ago #

    Can you tell me what plugins and widget you have active and are using?

  10. CapeCodBranding
    Member
    Posted 5 years ago #

    Hi Parkstreet,
    Sure can, there are quite a few...

    PlugIns;

    Add to Any
    Akismet
    All in One SEO
    Author Exposed
    Google Analytics for WordPress
    Similarity
    WordPress.com Popular Posts
    WordPress.com Stats
    WordPress.com Stats Helper
    WordPress Admin Bar
    WP-phpMyAdmin
    Wptouch iPhone Theme

    Since this morning I have deactivated WP-Cumulus and Collapsible Archive Widget (since I wasn't sure if either were causing a problem).

    My Widgets are;

    Recent Posts
    Popular Posts
    Links
    Blog Stats (via WordPress.com Stats Helper)
    and the WordPress Categories widget that comes preinstalled

    Plus a few Text widgets with Adsense and Feedburner code in them.

    I'm trying to take iridaix's advice and change my .htaccess to remove the 301 redirect I added. However that was almost a year ago and I don't remember how I did it, so I'm looking for my htaccess file. I'm not very technical, so I apologize if my questions and problems are very basic. :)

    Thanks!
    amy

  11. joshmac
    Member
    Posted 5 years ago #

    No need to apologize. We all have to learn the ins and outs of the software we use, so we are all learning together. I don't see any plugins or widgets that will give you the trouble you are having. Can you paste what you have in your .htaccess file?

  12. CapeCodBranding
    Member
    Posted 5 years ago #

    Thanks ParkStreet!

    I had to access my .htaccess file through my hosting company (iPower). I can't remember if there is a way to see it from wordpress (and in my FTP the file is blank). Here is what I got from it;

    Options +FollowSymlinks
    RewriteEngine on
    rewritecond %{http_host} ^www.capecodbranding.com [nc]
    rewriterule ^(.*)$ http://capecodbranding.com/$1 [r=301,nc]

    This is the only thing I see when I open it... not sure if there is supposed to be more.

    Thanks, amy

  13. joshmac
    Member
    Posted 5 years ago #

    Is this the code that WordPress generated? I thought it would usually be something like this:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME}!-f
    RewriteCond %{REQUEST_FILENAME}!-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress

    You may need to change it to RewriteBase /blog/ since your blog is in a subdirectory.

  14. joshmac
    Member
    Posted 5 years ago #

    Also, I am seeing something that I haven't see before.

    Warning: require(../reclamation/sidebar.php) [function.require]: failed to open stream: No such file or directory in /hermes/bosweb/web043/b431/ipw.theoccasionalcake/public_html/capecodbranding/blog/wp-content/themes/bluebird/category.php on line 5

    This appears when you go to http://capecodbranding.com/blog/category/apple/

  15. CapeCodBranding
    Member
    Posted 5 years ago #

    No, the 301 redirect is code that I entered into the .htaccess file manually last year. I googled to find the bit of code I'd need. I guess I didn't realize I could have WP generate for me. Should I use the code you posted instead?

    Looks like I've made my problem worse. I'm not sure what I've done in the last couple hours to make my category pages display the error that they are...
    I followed the trail in the error (wp-content/themes/bluebird/category.php) however, I don't have a category.php file in that theme (bluebird).

    Stumped. Still. :)

  16. iridiax
    Member
    Posted 5 years ago #

    You need some more troubleshooting:

    Rename the .htaccess files (to disable them) in your root and blog directory and see if categories work or not then. If they don't, you can then rename these files back to .htaccess to reactivate them.

    Disable all plugins and see if categories work then or not.

    Switch to the default theme and see if the categories work then or not.

  17. joshmac
    Member
    Posted 5 years ago #

    Yes @CapeCodBranding. I suggest using the code that I pasted above. That is the standard .htaccess code for WordPress. To fix the error message, I would suggest loading a fresh copy of the category.php file in your theme's folder.

  18. CapeCodBranding
    Member
    Posted 5 years ago #

    @iridiax I renamed the .htaccess files (both root and blog). However, I think I'll need to fix my 'other' problem, the error on the cat pages, first before I'll know what I'm up against. Thanks for the assistance, hopefully I'll get it figured out tonight. :)

    @ParkStreet The theme I'm using didn't have a category.php file to begin with. I've checked my backup copy, AND downloaded a fresh copy from the designer.... no category.php. Since it didn't have one initially, do I need one now (I know that may be a silly question) and if I do need one, is there a 'standard' version I can add to my theme. I'm not sure if that is the kind of thing I can just find in a universal format and add?

    Thanks again!

  19. joshmac
    Member
    Posted 5 years ago #

    If there was not one there to begin with then, I wouldn't add it, but then I don't understand your error message. Why is it looking for category.php? Also, if you are using the theme I think you are using, make sure the following files are there: r_sidebar.php, l_sidebar.php, & sidebar.php.

  20. CapeCodBranding
    Member
    Posted 5 years ago #

    OK! Here is what I did;

    1. reinstalled my theme (bluebird) and replaced the new stylesheet with my old one. Added all my images back in and added my favicon back to the header.php.
    2. Changed the 301 redirect code on my .htaccess file to the code Parkstreet gave me (from earlier in this thread).
    3. Enabled my .htaccess files by renaming them back to ".htaccess" (yesterday I had renamed them to disable).
    4. Activated WP-Cumulus and put the widget back in my sidebar.

    Now my categories work, and no error message! Yay!

    Just one more question, @Parkstreet, you found a link structure yesterday that pulled up a category page that had all my articles in list form. As it stands now, when you click a category it pulls up the full articles. Is it an easy fix to get the list of posts to show instead?

    Thanks so much to everyone for all of their help!!!

    amy

  21. joshmac
    Member
    Posted 5 years ago #

    Hmmm, not sure. Your new url structure to the list is http://capecodbranding.com/blog/posts/sorted-by-category/apple/ Without knowing where /posts/ and /sorted-by-category/ is coming from and how it is being generated, its a little difficult to figure out a fix. Also, you have this structure: http://capecodbranding.com/blog/posts/sorted-by-category/ and this structure: http://capecodbranding.com/blog/posts/ Do you know if Articles is a page? Also, it is setup like an archive page. Not sure if that helps or not.

  22. CapeCodBranding
    Member
    Posted 5 years ago #

    Ok, I know where those are coming from; Articles is a page we created, but it's actually called 'posts' in the permalink (it was renamed as Articles recently to be more descriptive and the permalink stayed the original name). Also, "Sorted by Category" is a child page of Posts (Articles). We update those pages ourselves because we couldn't find a category widget that broke down the categories into sections by date or topic. The problem is that we have a hard time keeping it up-to-date and error-free and it would be great to find an option that is automated.

    I went back and looked at my permalinks and found I had entered "post/category" for the Category Base. I'm not sure now why I did that, I've made so many changes the last couple of days my head is spinning... Anyway, I removed it and now my categories direct to;

    http://capecodbranding.com/blog/category/apple/

    Still in full article format, so it didn't change anything over how it was before (other than it now goes to where it should w/o any of my manually added pages in the link). So now I just need to find a way to have my articles show title only when they come up in the category list.

    Thanks again for all the help!

  23. joshmac
    Member
    Posted 5 years ago #

    No problem, I am glad that you finally got it sorted out. I will be thinking about the list page and if I come up with anything, I will let you know.

  24. joshmac
    Member
    Posted 5 years ago #

    Ok, so I was looking at the files included in the theme you are using. The same code/structure is used for both the index.php and single.php files. I believe that you will need to change some code in the single.php file from this:

    <?php the_content('Continue reading  &raquo;'); ?>

    To this:

    <?php //the_content('Continue reading  &raquo;'); ?>

    I am not sure what is going to happen when you click on the title link, but this will let you see if this is the file you need to be looking at in order to create a category list. If it doesn't work, then revert the changes you made.

  25. CapeCodBranding
    Member
    Posted 5 years ago #

    Hi Parkstreet,

    Thanks for all the time you are devoting to my problem. It means a lot to me. :)

    I've made the changes you suggested. I haven't changed it back yet, even though it doesn't appear to do what we'd hoped. The articles still show in full text, then when you click on the title it goes to just the title.

    Does this teach us what the next step should be?

    Thanks!
    amy

  26. joshmac
    Member
    Posted 5 years ago #

    Hmmm, I figured as much. Ok, now revert the changes you made to the single.php file and create a category.php file with the following information:

    <?php get_header(); ?>
    
        <div id="content">
    
    	<?php if (have_posts()) : ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    <!-- item -->
    				<div class="item entry" id="post-<?php the_ID(); ?>">
    				          <div class="itemhead">
    				            <h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>
    				            <div class="date"><?php the_time('F jS, Y') ?> </div>
    
    								<?php //the_content('Continue reading  &raquo;'); ?>
    
    				          <small class="metadata">
    							 Filed under <span class="category"><?php the_category(', ') ?> </span> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('Comment (0)', ' Comment (1)', 'Comments (%)'); ?></small>
    							 <div style="clear:both;"></div>
    <div style="clear:both;"></div>
    				 </div></div>
    <!-- end item -->
    
    <?php comments_template(); // Get wp-comments.php template ?>
    
    		<?php endwhile; ?>
    
    		<div class="navigation">
    			<div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
    			<div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
    			<p> </p>
    		</div>
    
    	<?php else : ?>
    
    		<h2 class="center">Not Found</h2>
    		<p class="center">Sorry, but you are looking for something that isn't here.</p>
    
    	<?php endif; ?>
    <!-- end content -->
    
    	</div>
    	<div id="secondary">
    
    <?php include(TEMPLATEPATH."/l_sidebar.php");?>
    
    <?php include(TEMPLATEPATH."/r_sidebar.php");?>
    
    	</div>
    <?php get_footer(); ?>
  27. CapeCodBranding
    Member
    Posted 5 years ago #

    Perfect! Now a category redirects here;

    http://capecodbranding.com/blog/category/apple/

    Any way to make the font smaller? I couldn't find any font size html in the code.

    Thanks, thanks, thanks!

  28. joshmac
    Member
    Posted 5 years ago #

    Are you looking to make the font smaller throughout your website or only on this page?

  29. CapeCodBranding
    Member
    Posted 5 years ago #

    Only on this page. I noticed that the titles are much bigger than on other pages. The rest of the text is fine, I'd just like to make the titles smaller so they don't run off the edge into my sidebar.

  30. joshmac
    Member
    Posted 5 years ago #

    Ok, in category.php, change this:

    <h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>

    to this

    <h1 class="cat-title"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>

    Then in your stylesheet, add this:

    h1.cat-title {
    font-size:.9em;
    }

    You may need to play around with it, if .9em is too small then try 1em, 1.1em, 1.2em, and so on.

Topic Closed

This topic has been closed to new replies.

About this Topic