[wp-trac] [WordPress Trac] #23635: get_objects_in_term - identify matching terms

WordPress Trac noreply at wordpress.org
Fri Apr 9 16:17:23 UTC 2021


#23635: get_objects_in_term - identify matching terms
--------------------------------------+---------------------
 Reporter:  leepowers                 |       Owner:  (none)
     Type:  enhancement               |      Status:  new
 Priority:  normal                    |   Milestone:
Component:  Taxonomy                  |     Version:  3.5.1
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+---------------------

Comment (by donmhico):

 Thank you for this ticket @leepowers. I know it's been many years now but
 I attached a PR that does what you suggested.

 Example Usage

 {{{#!php
 <?php
 // Default
 $objects = get_objects_in_term( array( 4, 3 ), 'my_taxonomy' );
 var_dump( $objects );
 /*
  * Output
    array(5) {
        [0]=>
        string(2) "21"
        [1]=>
        string(2) "26"
        [2]=>
        string(2) "26"
        [3]=>
        string(2) "28"
        [4]=>
        string(2) "42"
    }
  */

 $format_objects = get_objects_in_term( array( 4, 3 ), 'my_taxonomy',
 array( 'format' => true ) );
 var_dump( $format_objects );
 /*
  * Output
    array(2) {
        [3]=>
            array(3) {
                [0]=>
                string(2) "21"
                [1]=>
                string(2) "26"
                [2]=>
                string(2) "28"
            }
        [4]=>
            array(2) {
                [0]=>
                string(2) "26"
                [1]=>
                string(2) "42"
            }
    }
  */
 }}}

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


More information about the wp-trac mailing list