• Resolved Ale12

    (@ale12)


    Hello,

    Hope you have nice warm day.

    Can you direct me to documentation about category/taxonomy admin panel data populate process, please?

    I need to modify or filter the data that will be displayed on the taxonomy admin panel.

    If there are other functions/admin/hook for this, could you please let me know?

    Thank you very much for your time and your help.

    Best regards,

    -Ale12

Viewing 1 replies (of 1 total)
  • Thread Starter Ale12

    (@ale12)

    The category or taxonomy manage panel get populated by get_terms function.

    I found that in there is a file call wp-admin\includes\class-wp-terms-list-table.php to populate data in either category or taxonomy table in the manage page

    Here is the code excerpt from the file above

    function display_rows_or_placeholder() {
    		$taxonomy = $this->screen->taxonomy;
    
    		$args = wp_parse_args( $this->callback_args, array(
    			'page' => 1,
    			'number' => 20,
    			'search' => '',
    			'hide_empty' => 0
    		) );
    
    		extract( $args, EXTR_SKIP );
    
    		$args['offset'] = $offset = ( $page - 1 ) * $number;
    
    		// convert it to table rows
    		$count = 0;
    
    		$terms = array();
    
    		if ( is_taxonomy_hierarchical( $taxonomy ) && !isset( $orderby ) ) {
    			// We'll need the full set of terms then.
    			$args['number'] = $args['offset'] = 0;
    		}
    
    		$terms = get_terms( $taxonomy, $args );
    
    		if ( empty( $terms ) ) {
    			list( $columns, $hidden ) = $this->get_column_info();
    			echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">';
    			$this->no_items();
    			echo '</td></tr>';
    			return;
    		}
    
    		if ( is_taxonomy_hierarchical( $taxonomy ) && !isset( $orderby ) ) {
    			if ( !empty( $search ) ) // Ignore children on searches.
    				$children = array();
    			else
    				$children = _get_term_hierarchy( $taxonomy );
    
    			// Some funky recursion to get the job done( Paging & parents mainly ) is contained within, Skip it for non-hierarchical taxonomies for performance sake
    			$this->_rows( $taxonomy, $terms, $children, $offset, $number, $count );
    		} else {
    			$terms = get_terms( $taxonomy, $args );
    			foreach ( $terms as $term )
    				$this->single_row( $term );
    			$count = $number; // Only displaying a single page.
    		}
    	}

    However if you want to filter the taxonomy or category value in its table you don’t need to go into this file

    rather you will create a function() and use add_filter(‘get_term_args’, ‘my_filter_function’,10,2)
    function my_filter_function($args){

    //code goes here
    return $args;
    }

    then add the add_filter and function to your theme’s functions.php

    all credit goes to: Mamaduka and his code in the link below
    https://wordpress.stackexchange.com/questions/30911/excluding-categories-from-manage-categories-using-a-get-terms-filter

Viewing 1 replies (of 1 total)
  • The topic ‘How category or taxonomy data on its admin panel get populated?’ is closed to new replies.