Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have the following custom post type

        register_post_type('cp_clients', array(
            'labels' => array(
                'name' => __('Clients'),
                'singular_name' => __('Client')
            ),
            'public' => true,
            'has_archive' => true,
            'supports' => array('thumbnail', 'title', 'editor')
                )
        );

I want to output custom content when the user calls http://blogurl.com/companies. It's a plug-in and not a theme.

Any ideas how I can redirect to a custom page/output for this URL?

share|improve this question
    
You're not that cleat about what you're looking to do. Please revise your question. –  Kevin Langley Jr. Nov 4 '11 at 14:25

3 Answers 3

up vote 2 down vote accepted

I don't think you need a redirect. You are missing the rewrite rule for your custom post type.

register_post_type('cp_clients', array(
    'labels' => array(
        'name' => __('Clients'),
        'singular_name' => __('Client')
    ),
    'public' => true,
    'has_archive' => true,
    'supports' => array('thumbnail', 'title', 'editor')
    'rewrite' => array('slug'=>'companies')
);

You should now be able to create and use single-cp_clients.php, and archive-cp_clients.php template files. And your urls will look like example.com/comapnies and example.com/comapnies/acmecorp

share|improve this answer

I'm not sure I understand your question.

I've used this Redirection plugin successfully before, but it looks like it's been updated fairly substantially since.

share|improve this answer

Thank you for your answers. I found a solution to the problem. The solution is to use "template_redirect" and to detect if the page is the post type archive page

 if ($wp_query->query_vars['post_type'] === 'cp_companies' && $wp_query->query_vars['name'] === '') {

}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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