0

Before I proceed on writing anything just have a look the following images. (snapshots)

enter image description here enter image description here enter image description here

I have one custom post type by name 'questions' just like we have 'posts/pages'. If you look at the image one, you can find that. And I found categories in that too. When I click on one of the categories in that (like Apostasy which has 1 article), I found that in categories of the questions (have a look at the image-2 for seeing that posts). Now, when I begin to edit that article (as you asked me in the question), I find 'categories on the right side as it supposed to be and it is no doubt have tick marks on the respected categories which my client needed. When I click on update. The questions are moving to the url fatwaa.com/questions/post-title. Whereas, when you look at the categories, you found zero posts.

I then soon back posted a test article in the 'Post' Section by ticking mark the respected category then without any difficulty I'm getting that in the category. I have edited one archive and tick mark one category into that and it is working without any difficulty.

So, I think the whole problem is causing due to this 'Questions Template'.

Also on the home page whenever I go to any category it is displaying same posts again and again..

(here is the code of the home page) http://pastebin.com/5LqnwAzY

1

If the Categories referred to here are the WordPress native category taxonomy, the queries for these term pages by default will only include the native post post type.

To add custom post types to category term queries, you can add a bit of code to your theme's functions.php file, which modifies these queries via the pre_get_posts action to add your custom post type:

function wpa_category_custom_type( $query ) {
    if ( $query->is_category() && $query->is_main_query() ) {
        $query->set( 'post_type', array( 'post', 'questions' ) );
    }
}
add_action( 'pre_get_posts', 'wpa_category_custom_type' );

The above assumes your post type is registered as questions.

  • Well it didn't work either and I'm still unable to see any posts via category (which is posted via custom_post_type 'questions').Well I just want to ask that will custom post type also uses permalink? If so, then is it its problem? – shoaib mirza May 21 '13 at 7:30
  • In the code you linked, you refer to the post type as question, singular, not questions plural. did you change the code above to correctly reference your post type as question? – Milo May 21 '13 at 15:24
  • also, read this question/answer. – Milo May 21 '13 at 15:26
  • Yes, I even tried by using 'question'. Well, one more thing is that it is definitely working with 'Posts'. I mean if we directly go to the posts and from there if we post and give categories then it is defintely working. Please find the function.php code here pastebin.com/R849Nhpk – shoaib mirza May 21 '13 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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