WordPress.org

Support

Support » Plugins and Hacks » Category Meta plugin » [Plugin: Category Meta plugin] Display post "if"

[Plugin: Category Meta plugin] Display post "if"

Viewing 2 replies - 1 through 2 (of 2 total)
  • Gyroscopic

    @gyroscopic

    Hi Alex

    I have done this with the following code…

    $sql = "SELECT terms_id FROM prefix_termsmeta WHERE meta_key = 'my_key_name' AND meta_value = 'my_key_value'; ";
    
    $included_categories = $wpdb->get_col( $wpdb->prepare($sql));
    
    if ($included_categories != NULL ) {
    	// Create comma delimited list of included categories...
    	$included_categories_list = implode(", ",$included_categories);
    } 
    
    // Now get the select list of thse categories I found...
    wp_dropdown_categories('id=my_select_id&name=my_select_name&show_count=0&hierarchical=1&depth=1&show_last_update=0&hide_empty=0&include='.$included_categories_list.'&orderby=name&taxonomy=my_custom_taxonomy&echo=1');

    It uses the wp_dropdown_categories() function to display an HTML select tag populated with the taxonomy terms. (see codex for full set of arguments!) I just select all the terms I want with a simple sql statement and pass the list to the function.

    However, I have found that this plugin does not save the meta field against the term if the checkbox is empty, therefore you cannot select terms that do NOT have the checkbox checked! Which is something I am also trying to achieve :/

    Hope that helps!

    Thx Gyroscopic, I’ll try that 🙂

    Regards!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Category Meta plugin] Display post "if"’ is closed to new replies.
Skip to toolbar