• Resolved mibrad_za

    (@mibrad_za)


    When sending out Email notifications using the {CATS} and {TAGS} elements in the email template, nothing is picked up even though thy are now be pulled in elsewhere in the plugin?

    Code used in standalone plugin to enable custom taxonomy:

    function my_taxonomy_types($taxonomies) {
    $taxonomies[] = ‘events_categories’;
    return $taxonomies;
    }
    add_filter(‘s2_taxonomies’,’my_taxonomy_types’);

    which as I say works fine elsewhere in the plugin.

    http://wordpress.org/plugins/subscribe2/

Viewing 7 replies - 1 through 7 (of 7 total)
  • @mibrad_za,

    Which Event Calendar plugin are you using? Have you also registered the custom post type?

    Thread Starter mibrad_za

    (@mibrad_za)

    Its the All in One Event Calender by Time.ly ver 1.11.4

    The code for registering custom post types are in the same standalone plugin.

    function my_post_types($types) {
    $types[] = ‘ai1ec_event’;
    return $types;
    }
    add_filter(‘s2_post_types’,’my_post_types’);

    which all works fine.

    @mibrad_za,

    This has been raised before, some code that worked is contained in this post (I think you need to add another taxonomy type perhaps):

    http://wordpress.org/support/topic/plugin-subscribe2-notifications-for-customer-events?replies=31#post-3256055

    But note that the event MUST be save as draft rather than published immediately after typing or you get an error.

    Thread Starter mibrad_za

    (@mibrad_za)

    I’m only wanting one type of custom taxonomy so that is fine.

    Please also understand that the plugin is working fine with the custom taxonomy code used except for in the email template where I use the {CATS} element to bring in the custom taxonomy. Should I create another element for this and where would I start to look?

    @mibrad_za,

    Okay, let’s try some investigating. Find an ID number for a post made into the custom posy type and then called this function with that id:

    £post_IID = 1; // the post ID number
    $cats = wp_get_object_terms($post_ID, 'events_categories', array('fields' => 'names'));
    var_dump($cats);

    Does that output an array of custom category names?

    Thread Starter mibrad_za

    (@mibrad_za)

    Would it not be here somewhere?

    function all_cats($exclude = false, $orderby = 'slug') {
    		$all_cats = array();
    		$s2_taxonomies = apply_filters('s2_taxonomies', array('category'));
    
    		foreach( $s2_taxonomies as $taxonomy ) {
    			if ( taxonomy_exists($taxonomy) ) {
    				$all_cats = array_merge($all_cats, get_categories(array('hide_empty' => false, 'orderby' => $orderby, 'taxonomy' => $taxonomy)));
    			}
    		}
    
    		if ( $exclude === true ) {
    			// remove excluded categories from the returned object
    			$excluded = explode(',', $this->subscribe2_options['exclude']);
    
    			// need to use $id like this as this is a mixed array / object
    			$id = 0;
    			foreach ( $all_cats as $cat) {
    				if ( in_array($cat->term_id, $excluded) ) {
    					unset($all_cats[$id]);
    				}
    				$id++;
    			}
    		}
    
    		return $all_cats;

    I tried replacing the array(‘category’) with array(‘events_categories’) but still ended up with nothing..

    @mibrad_za,

    No, it’s nothing to do with that because that line:
    $s2_taxonomies = apply_filters(‘s2_taxonomies’, array(‘category’));

    Creates a variable contained the default taxonomy (which is ‘categories’) and adds to it anything added by a custom taxonomy filter (like the code you wrote that adds ‘ai1ec_event’.

    If you can run this code:

    $post_ID = 1; // the post ID number
    $cats = wp_get_object_terms($post_ID, 'events_categories', array('fields' => 'names'));
    var_dump($cats);

    We can find out if WordPress thinks the post contains any categories in the first place and maybe identify the issue.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Custom Taxonomy’ is closed to new replies.