Support » Fixing WordPress » Display Custom taxonomy terms in Backend

  • Resolved pixelschupser-nw


    Hello there,

    i used a custom post type to create a slideshow function.
    Posts act as slides, categories act as slideshow groups.

    What i’m trying to do now is a way to display the created slideshow groups (terms) as a dropdown (select) list on the side of the wordpress page editor.
    The idea is to be able to create a page and select one of the created slideshows (category). The slug of the selected slideshow gets stored in a variable, so i can output it on the frontend.

    I know how to create meta_boxes, the basics that is.
    This function is a bit over my head, this is why i need your help.

    The basic slideshow functions are working, now i need a way to select and store / display them.

    Thanks in advance and best regards!


    EDIT: I already started with the code, but i need some advice how to pass / store the variables:

    <?php $terms = get_terms( 'slideshow' ); $count = count($terms); ?>
    <?php if ( $count > 0 ) { ?>
    <select name="meta_slideshow_category">
        <option selected="selected" value="none"><?php _e( 'No Slideshow', 'language' ); ?></option>
        <?php foreach ( $terms as $term ) { ?>
        <option value="<?php echo $term->slug; ?>"><?php echo $term->name; ?></option>
        <?php } ?>
    <?php } ?>

Viewing 1 replies (of 1 total)
  • Nevermind, figured it out by myself.
    It wasn’t as hard as i imagined it would be.

    add_action( 'add_meta_boxes', 'add_page_metaboxes' );
    function add_page_metaboxes() { add_meta_box('page_metaboxes', 'Slideshow', 'page_metaboxes', 'page', 'side', 'high'); }
    function page_metaboxes(){
        global $post;
        $custom = get_post_custom($post->ID);
        $meta_slideshow_category = get_post_meta($post->ID, 'meta_slideshow_category', true);
        if (!$meta_slideshow_category) $meta_slideshow_category = 'none';
        $terms = get_terms( 'slideshow' ); $count = count($terms);
        <?php if ( $count > 0 ) { ?>
        <div class="misc-pub-section">
            <p><strong><?php _e('Choose Slideshow', 'language'); ?></strong></p>
            <select name="meta_slideshow_category">
                <option<?php if ( $meta_slideshow_category == '' || $meta_slideshow_category == 'none' ) { echo ' selected="selected"'; } ?> value="none"><?php _e( 'Display nothing', 'language' ); ?></option>
                <?php foreach ( $terms as $term ) { ?>
                <option<?php if ( $meta_slideshow_category == $term->slug ) { echo ' selected="selected"'; } ?> value="<?php echo $term->slug; ?>"><?php echo $term->name; ?></option>
                <?php } ?>
        <?php } else { ?>
        <p><?php _e('No Slideshows have been created', 'language'); ?></p>
        <?php } ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Display Custom taxonomy terms in Backend’ is closed to new replies.