0

I have a website that has a news section which simply shows the most recent 6 posts with a category of news. The problem is that whenever you create a post, Wordpress automatically creates a page for that post. The client claims Google does not like it when you have content showing up on a news section as well as on useless post pages which are not even being linked to.

My question is this: is it possible to duplicate this news section usability (keeping it user-friendly) without having Wordpress create a new post page for every single news item that is published?

And I don't mean just simply excluding the posts from a general post page, because that is already being accomplished. I mean not even generating a page for that post.. That would require a different method (rather than publishing a news item through a post), and I was wondering if said method exists

EDIT:

Thanks to @Rarst, I think I may be getting closer. I performed a test with custom_post_types with the following code:

add_action( 'init', 'create_post_type' );
function create_post_type() {
    register_post_type( 'acme_product',
        array(
            'labels' => array(
                'name' => __( 'Products' ),
                'singular_name' => __( 'Product' )
            ),
        'public' => true,
        'has_archive' => false,
        'rewrite' => array(
            'pages' => false
            )
        )
    );
}

The problem is, I create a new "product" (it should really be "news", but this is just the example provided in the Wordpress documentation), and while it is not archived, a page is still created with the url: http://mydomain.com/?acme_product=test , where 'test' changes based on the name I gave the "product". Is there a way to prevent the site from publishing this page?

Thanks!

4
  • if the posts aren't being linked to, how exactly is google crawling them?
    – Milo
    Commented Sep 9, 2011 at 3:12
  • Have you looked at custom post types? they are there to help in situations like these. Commented Sep 9, 2011 at 9:19
  • @Milo: To be honest, I'm not compeltely sure...
    – Amit
    Commented Sep 9, 2011 at 17:16
  • @Hameedullah Khan: What do you mean custom post types? What will that allow me to do ?
    – Amit
    Commented Sep 9, 2011 at 17:16

1 Answer 1

1

As per comments see Custom Post Types in Codex.

Essentially:

  • posts are posts of post type;

  • pages are posts of page type;

  • you can register your own custom types to use for your specific needs.
5
  • Would I be able to define a post type that only publishes to the "news" section, but doesn't actually create a page for that post ?
    – Amit
    Commented Sep 12, 2011 at 23:08
  • Please see EDIT to question
    – Amit
    Commented Sep 13, 2011 at 0:15
  • @Amit well, if you disable archive and not link to those pages they will be essentially invisible. If you want to kill them the easiest would probably be to hook into template_redirect, check for them and redirect to home page or throw 404 error.
    – Rarst
    Commented Sep 13, 2011 at 8:53
  • I think that could be a viable solution, how would you hook them into a template_redirect? There's no Wordpress documentation on it. Thanks!
    – Amit
    Commented Sep 13, 2011 at 12:18
  • @Amit hooking, well - as hooking usual works. For redirect wp_safe_redirect() and die()
    – Rarst
    Commented Sep 13, 2011 at 12:41

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.