0

I have a custom "about" post:

function about_register() {
        $labels = array(
            'name' => _x('About Page', 'post type general name'),
            'singular_name' => _x('About Item', 'post type singular name'),
            'add_new' => _x('Add New', 'About Item'),
            'add_new_item' => __('Add New About Item'),
            'edit_item' => __('Edit About Item'),
            'new_item' => __('New About Item'),
            'view_item' => __('View About Item'),
            'search_items' => __('Search Team'),
            'not_found' =>  __('Nothing found'),
            'not_found_in_trash' => __('Nothing found in Trash'),
            'parent_item_colon' => ''
        );

        $args = array(
            'labels' => $labels,
            'public' => true,
            'publicly_queryable' => true,
            'show_ui' => true,
            'query_var' => true,
            'rewrite' => true,
            'capability_type' => 'post',
            'hierarchical' => false,
            'menu_position' => null,
            'has_archive' => 'about',
            'supports' => array('title','thumbnail')
        );

        register_post_type( 'custom_about_post' , $args );
    }

I created a page called archive-about.php and put my Wordpress loop in there and pulled up my custom meta information.

However, when I go to mysite.com/about I get a 404 error.

Searching the internet -

I went to my permalinks page and tried to flush rewrite rules by hitting save.

I was instructed to put the following into my sites .htaccess file:

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

# END WordPress

However, when I did this my entire site is now 403! If I remove this and leave my .htaccess file blank my site returns...but the link

localhost/mysite/about/ 

still doesn't work.

In order to make the archives work, do I use the default settings in permalinks or something else?

What should I be setting my rewrite rules to in Mac OSX (snow leopard) to run Wordpress locally?

Is there something wrong in the code posted above?

7
  • Have you flushed your rewrite rules by going to Settings/Permalinks and saving permalink structure?
    – soulseekah
    Mar 9, 2012 at 21:05
  • Done that...it's in my description above. Mar 9, 2012 at 21:06
  • Does my permalink structure have to be anything special or can I just use the default in order to see my custom post type archive? Mar 9, 2012 at 21:07
  • Sorry, must have skimmed past over that line :) Seems like 'has_archive' => 'about' is incorrect first of all, it has to be either true or false, refer to codex.wordpress.org/Function_Reference/register_post_type
    – soulseekah
    Mar 9, 2012 at 21:10
  • That seems to be the main problem. Will add an answer shortly.
    – soulseekah
    Mar 9, 2012 at 21:11

3 Answers 3

2

You named the custom post type 'custom_about_post' not 'about'. Rename the archive template to archive-custom_about_post.php or better: rename the post type.

As a rule of thumb: Avoid underscores in post type names. There are/were some issues, especially with templates.

And why do you need a custom post type just for about pages? What’s your goal?

2
  • The about page needs 9 separate text boxes with different content. I suppose I could just use a custom meta box...can I do that for a generic post? It's the only post I want the text boxes for Mar 9, 2012 at 21:12
  • You could check if the post meta _wp_page_template matches your template and display the meta boxes only if it does.
    – fuxia
    Mar 9, 2012 at 21:23
1
  1. Permalinks has to be set to something other than default.

  2. Maybe because I was on a Mac I had to set the following in my .htaccess file to get rid of the 403 error:

    Options +FollowSymLinks

So the entire rewrite file is:

Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /mysite/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /mysite/index.php [L]
</IfModule>
0

As register_post_type shows, the rewrite argument is used incorrectly in your case. It has to be an array probably. The slug key would let you set your slug to about as required.

function about_register() {
    $args = array(
        ...
        'has_archive' => true,
        'rewrite' => array( 'slug' => 'about' ),
        'supports' => array('title','thumbnail' )
    );

    register_post_type( 'custom_about_post' , $args );
}

Otherwise, as per:

...true and use post type as slug...

...your slug is being overridden.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.