• after enabling tags & categories for attachments, I want attachments to be displayed at the tag page.

    to enable tag & categories I’ve used the following script

    function wptp_add_categories_to_attachments() {
    	    register_taxonomy_for_object_type( 'category', 'attachment' );
    	}
    	add_action( 'init' , 'wptp_add_categories_to_attachments' );
    
    	function wptp_add_tags_to_attachments() {
    	    register_taxonomy_for_object_type( 'post_tag', 'attachment' );
    	}
    	add_action( 'init' , 'wptp_add_tags_to_attachments' );

    I used the following script to display all custom post types with the requested tag, but I thought attachments are also included.

    function post_type_tags_fix($request) {
    	    if ( isset($request['tag']) && !isset($request['post_type']) ) {
    			$request['post_type'] = 'any';
    			//$request['post_type'] = array('post','feature','attachment');
    	    }
    	    return $request;
    	}
    	add_filter('request', 'post_type_tags_fix');

    When I manually add attachments it doesn’t show any attachments. Somebody knows how to fix this?

The topic ‘Include attachments at tag page’ is closed to new replies.