1

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?

1
  • You're not that cleat about what you're looking to do. Please revise your question. Commented Nov 4, 2011 at 14:25

3 Answers 3

3

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

0

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.

0

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'] === '') {

}

Your Answer

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

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