[wp-trac] [WordPress Trac] #25267: PHP notices in register_post_type()

WordPress Trac noreply at wordpress.org
Sun Apr 27 00:43:24 UTC 2014


#25267: PHP notices in register_post_type()
-------------------------------+----------------------
 Reporter:  Looimaster         |       Owner:
     Type:  defect (bug)       |      Status:  closed
 Priority:  normal             |   Milestone:
Component:  Posts, Post Types  |     Version:  3.6
 Severity:  normal             |  Resolution:  invalid
 Keywords:                     |     Focuses:
-------------------------------+----------------------
Changes (by DrewAPicture):

 * status:  new => closed
 * resolution:   => invalid
 * milestone:  Awaiting Review =>


Old description:

> Code: http://pastebin.com/P4Ac7seu
>
> What I get when entering:
> 1) http://localhost/portfolio_category/motion/ - nothing found (content-
> none.php)
> 2) http://localhost/portfolio_category/motion/?post_type=portfolio -
> found a few posts but there is also `NOTICE: UNDEFINED PROPERTY:
> STDCLASS::$LABELS IN C:\WAMP\WWW\WP-INCLUDES\GENERAL-TEMPLATE.PHP ON LINE
> 700` twice
> 3) http://localhost/?portfolio_category=motion&post_type=portfolio -
> found a few posts but there is also `NOTICE: UNDEFINED PROPERTY:
> STDCLASS::$LABELS IN C:\WAMP\WWW\WP-INCLUDES\GENERAL-TEMPLATE.PHP ON LINE
> 700` twice
> 4) http://localhost/?portfolio_category=motion - nothing found (content-
> none.php)
> 5) http://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.

New description:

 Code:
 {{{
 #!php
 <?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.

--

Comment:

 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.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/25267#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list