Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

Ale12 on "adding 'author_id' as part of register_taxonomy parameter- How to"

$
0
0

Hello,

Hope you all well.

I would like to have a list of taxonomies by author. I searched google and WordPress forum and There are couple answers which were closed. However, it does not fit blog's requirement

The blog that we run is a multi-authors blog with different user role.

Here are some questions.

Can I add "author=>$current_user->id" to taxonomy.php file and get a list of taxonomy by author using function WP_Tax_Query($author_id)?

Please see the block of code below

If there is no option to get taxonomy by author available and I have to add author to taxonomy.php above, What other files that code need to be changed for example, template/core files and database table? Could you please let me know the files' name.

What would be a recommended practice so that when new Wordpress release, it would be easy to maintain and update?

global $current_user; // will add code
function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
	global $wp_taxonomies, $wp;

	if ( ! is_array( $wp_taxonomies ) )
		$wp_taxonomies = array();

	$defaults = array(
		'labels'                => array(),
		'description'           => '',
		'public'                => true,
		'hierarchical'          => false,
		'show_ui'               => null,
		'show_in_menu'          => null,
		'show_in_nav_menus'     => null,
		'show_tagcloud'         => null,
		'meta_box_cb'           => null,
		'capabilities'          => array(),
		'rewrite'               => true,
		'query_var'             => $taxonomy,
		'update_count_callback' => '',
		'_builtin'              => false,
                'author'                => $current_user->id, /not sure if I need a comma here ***will add code here **/
	);
	$args = wp_parse_args( $args, $defaults );

I think it might be helpful if we can list a category/taxonomies by authors but I might be wrong.

Thanks very much for your help.

Have a nice, warm and sunny day.
-A


Viewing all articles
Browse latest Browse all 8245

Trending Articles