Support » Fixing WordPress » post type single posts think they are attachments

  • I have a custom post type ‘cwslis_news’ which holds news stories for my site. The read more links where loading the appropriate single.php but ‘something’ has changed and now they loading the index.php.

    When I dig into the base code and look at the value of the post query contains:

    [request] => SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_name = ‘test’ AND wp_posts.post_type = ‘attachment’ ORDER BY wp_posts.post_date DESC

    where the name is right but the post_type should be ‘cwslis_news’ not ‘attachment’.

    This is the same for all my old and new post under cwslis_news. All the records in the posts table have the post_type ‘cwslis_news’ so presumably something somwhere else has decided that pages on /wordpress/cwslis_news/[xxxx] are all type = attachment not type = cwslis_news

    Any ideas how I can change this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter horaland

    (@horaland)

    OK, further digging
    the URL is /cwslis_news/test/
    and for some reason the rewrite rule that matches is:

    [[^/]+/([^/]+)/?$] => index.php?attachment=$matches[1]

    which as I understand it is [somthing]/[somthing]/[somthing or nothing]

    which seems a very open rule, I’m not surprised it matches but why would such a big catch all rule return ‘attachment’ as the post type?

    Did you ever solve this? This is happening on a default install of http://wordpress.org/plugins/simple-staff-list/

    It seems like a very open rule to me too. The rule is created in

    wp-includes/rewrite.php
    generate_rewrite_rules();

    So it seems to be a normal WP rule for attachments.

    It seems the attachment rule is overriding the custom post type rule.

    I would like a proper fix or determine if there is a bug in the staff plugin? I will post this in the staff plugin support too.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘post type single posts think they are attachments’ is closed to new replies.