Opened 11 years ago
Closed 10 years ago
#25267 closed defect (bug) (invalid)
PHP notices in register_post_type()
Reported by: | Looimaster | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.6 |
Component: | Posts, Post Types | Keywords: | |
Focuses: | Cc: |
Description (last modified by )
Code:
<?php function create_portfolio_post_type() { register_post_type( 'portfolio', array( 'public' => true, 'exclude_from_search' => true, 'has_archive' => true, 'supports' => array( 'title', 'editor', 'author', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes' ), 'rewrite' => array( 'slug' => 'portfolio-items' ) ) ); register_taxonomy( 'portfolio_category', 'portfolio', array( 'hierarchical' => true, 'show_ui' => true, 'query_var' => true, 'rewrite' => true, ) ); } add_action( 'init', 'create_portfolio_post_type' );
Original Pastebin: http://pastebin.com/P4Ac7seu
What I get when entering:
1) localhost/portfolio_category/motion/
- nothing found (content-none.php)
2) localhost/portfolio_category/motion/?post_type=portfolio
- found a few posts but there is also an "Undefined Property" notice in general-template.php
3) localhost/?portfolio_category=motion&post_type=portfolio
- found a few posts but there is also an "Undefined Property" notice in general-template.php
4) localhost/?portfolio_category=motion
- nothing found (content-none.php)
5) localhost/portfolio-items/
- works fine
Besides PHP notice I can't access single portfolio_category
archives unless I add ?post_type=portfolio
to the URL. Should it be this way?
Testing on Twenty Thirteen.
Change History (4)
#3
@
10 years ago
I was able to reproduce using trunk build but without any notices.
As a recap:
1) /portfolio_category/motion/ - nothing found
2) /portfolio_category/motion/?post_type=portfolio - found posts
3) /?portfolio_category=motion&post_type=portfolio - found posts
4) /?portfolio_category=motion - nothing found
5) /portfolio-items/ - works fine
I got the same behavior on items 3&4 using non-pretty permalinks.
#4
@
10 years ago
- Description modified (diff)
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
The post_type
var defaults to posts, so the only way #1 and #3 would work (short of passing your post type) is if there were posts in that taxonomy. As for the notices, I also can't reproduce. Feel free to reopen if you continue to see these issues.
Can't reproduce the notice here, I guess it's being caused by other custom code/plugins.
For the "nothing found" section - change your
'exclude_from_search' => true,
tofalse
if you want a proper listing.