• My doubt is related to the section: “Exceptions: Post Tags and Categories

    Using simply:

    function my_em_own_taxonomy_register(){
        register_taxonomy_for_object_type('category',EM_POST_TYPE_EVENT);
        register_taxonomy_for_object_type('category',EM_POST_TYPE_LOCATION);
        register_taxonomy_for_object_type('category','event-recurring');
    }
    add_action('init','my_em_own_taxonomy_register',100);

    The following shortcode calls are correct?

    [events_list post_category="featured,-hidden"]
    [locations_list post_category="featured,-hidden"]

    Otherwise, I can not register the standard “category” of wordpress and you, in the tutorial, recommend to register a “custom_category” instead?

    To understand us: with standard “category” I refer to the categories that can also be associated with post and pages

    PS This question is similar to: post_category-dont-work-as-filter, events-manager-using-post-categories

    • This topic was modified 7 years, 7 months ago by Raruto.
    • This topic was modified 7 years, 7 months ago by Raruto.
    • This topic was modified 7 years, 7 months ago by Raruto.
    • This topic was modified 7 years, 7 months ago by Raruto.
    • This topic was modified 7 years, 7 months ago by Jan Dembowski.
    • This topic was modified 7 years, 7 months ago by Raruto.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    at the moment you need to do custom coding to add those filter

    eg. https://wp-events-plugin.com/tutorials/creating-custom-event-search-attributes/

    Thread Starter Raruto

    (@raruto)

    Hi Angelo,
    but in this pastebin.com/ you say that EM is perfectly able to automatically register new taxonomies as searchable within itself (without the need to create a custom event search attribute ..), in fact, I tried to create some new taxonomies such as “post_category” and “custom_category“, and the result is as follows:

    function my_em_own_taxonomy_register(){
        register_taxonomy_for_object_type('custom_category',EM_POST_TYPE_EVENT);
    }
    add_action('init','my_em_own_taxonomy_register',100);

    WORKING: [events_list custom_category="featured"]

    function my_em_own_taxonomy_register(){
        register_taxonomy_for_object_type('post_category',EM_POST_TYPE_EVENT);
    }
    add_action('init','my_em_own_taxonomy_register',100);

    NOT WORKING: [events_list post_category="featured"]
    WORKING: [events_list post_post_category="featured"]

    This makes me think there is a kind of regex inside the plugin that should turn “category” into “post_category” (am I wrong?, according to what is written in the guide it would seem so…)

    PS in particular I refer to the paragraphs “Exceptions: Post Tags and Categories,” “Using Custom Taxonomies in Searches”

    • This reply was modified 7 years, 7 months ago by Raruto.

    Do you have any other custom post types running?

    Thread Starter Raruto

    (@raruto)

    Hi caimin,
    I did some further tests (only with the plugin EM running) and I came to the following result.

    Due to the reasons explained by your article I already had these two functions in the functions.php:

    function my_em_posttype_fix(){
    	register_taxonomy_for_object_type('category',EM_POST_TYPE_EVENT);
    	register_taxonomy_for_object_type('category',EM_POST_TYPE_LOCATION);
    }
    add_action('init','my_em_posttype_fix',100);
    function my_em_posttype_cat_default($EM_Object){
    	global $post;
    	if( $post->post_type == EM_POST_TYPE_EVENT || $post->post_type == EM_POST_TYPE_LOCATION ){
    		$categories = get_the_category();
    		if( count($categories) == 0 ){
    			//assign a category to this
    			wp_set_object_terms($post->ID, 'uncategorized','category');
    		}
    	}
    }
    add_action('template_redirect','my_em_posttype_cat_default', 1,1);

    Editing the first function, as follows, produces the duplication of the word “post” (or “post_post_category”, as described in the previous post):

    function my_em_posttype_fix(){
      $labels = array(
            'name' => 'post_category',
            'singular_name' => 'post_category',
            'search_items' => 'Search post_category',
            'all_items' => 'All post_category',
            'parent_item' => 'Parent post_category',
            'parent_item_colon' => 'Parent post_category:',
            'edit_item' => 'Edit post_category',
            'update_item' => 'Update post_category',
            'add_new_item' => 'Add New post_category',
            'new_item_name' => 'New post_category',
            'menu_name' => 'post_category Categories',
        );
        register_taxonomy('post_category',array(EM_POST_TYPE_EVENT), array(
            'hierarchical' => true,
            'labels' => $labels,
            'query_var' => true
        ));
    
        register_taxonomy_for_object_type('category',EM_POST_TYPE_EVENT);
        register_taxonomy_for_object_type('category',EM_POST_TYPE_LOCATION);
    }
    add_action('init','my_em_posttype_fix',100);

    From what I have been able to see, this issue specifically afflicts the category “post_category” (eg. with the “custom_category” there are no problems in keeping active the last two lines: “register_taxonomy_for_object_type”)

    PS Can you confirm me that I can not use the default wordpress category “category” as EM search attribute? (if not modifying the plugin core..)

    • This reply was modified 7 years, 6 months ago by Raruto.

    Which version of Events Manager and WordPress are you using?

    Thread Starter Raruto

    (@raruto)

    “Events Manager 5.7.3” and “WordPress 4.8.1”

    I also did a test from a fresh new install getting the same result..

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Using Additional Custom Taxonomies’ is closed to new replies.