Forum Replies Created

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter mikevisions

    (@mikevisions)

    Solved it.

    $mdmeta = get_term_meta( $term->term_id, 'wgmdt_term_show_free' );
       echo    ' <li> '.$mdmeta[0]. ' </li> ';

    Thanks for all your help.

    Thread Starter mikevisions

    (@mikevisions)

    I have just done a clean wordpress install on localhost and used the default CMB2 code and get the same result with a NULL return

    Thread Starter mikevisions

    (@mikevisions)

    Sadly that still does not work.
    Using var dump returns NULL
    I have tried this with the default CMB2 code for a text field and that does not display either.

    Thread Starter mikevisions

    (@mikevisions)

    This is the cmb2 code for generating the custom field

    add_action( 'cmb2_admin_init', 'yourprefix_register_taxonomy_metabox' );
    /**
     * Hook in and add a metabox to add fields to taxonomy terms
     */
    function yourprefix_register_taxonomy_metabox() {
    	$prefix = 'wgmdt_term_';
    
    	/**
    	 * Metabox to add fields to categories and tags
    	 */
    	$cmb_term = new_cmb2_box( array(
    		'id'               => $prefix . 'edit',
    		'title'            => __( 'Category Metabox', 'cmb2' ), // Doesn't output for term boxes
    		'object_types'     => array( 'term' ), // Tells CMB2 to use term_meta vs post_meta
    		'taxonomies'       => array( 'supplier_categories' ), // Tells CMB2 which taxonomies should have these fields
    		// 'new_term_section' => true, // Will display in the "Add New Category" section
    	) );
    	$cmb_term->add_field( array(
    		'name' => __( 'Show free entries', 'cmb2' ),
    		'desc' => __( 'field description (optional)', 'cmb2' ),
    		'id'   => $prefix . 'show_free',
    		'type'             => 'select',
        'show_option_none' => false,
        'options'          => array(
    	    'yes'   => __( 'Yes', 'cmb2' ),
            'no'   => __( 'No', 'cmb2' ),
    
          ),
    	) );
    }

    Thread Starter mikevisions

    (@mikevisions)

    Hi Michael,
    Thanks for your offer of help.
    I am using the get term meta from the codex. It is also the same format that I have working for custom post meta. I am using it in a custom taxonomy but have tried it in a standard category and got the same result so I don’t think it is anything to do with custom taxonomy or custom post type.
    ‘wgmdt_term_ is the prefix and show_free is the key for the custom field. I have confirmed that this is being saved in the termmeta table.

    $mdmeta = get_term_meta( term_id, 'wgmdt_term_show_free' );
    echo    ' <li> '.$mdmeta. ' </li> ';

    Thread Starter mikevisions

    (@mikevisions)

    Hi Michael,
    var_dump gives me bool(false)
    If I echo the term id it prints out correctly.
    Removing the custom field key so that all meta data prints out also gives me bool(false)
    I am at a loss to understand what is going on.

    Thread Starter mikevisions

    (@mikevisions)

    Thanks for that. I was looking at Taxonomy rather than term.
    This is the code I came up with;

    <?php $term = get_term_by(‘slug’, ‘gifts’, ‘business_category’); $name = $term->name;
    if($name) {
    echo ‘ print something ‘;
    } ?>

    Thread Starter mikevisions

    (@mikevisions)

    I was thinking a redirect via ht access?

    Thread Starter mikevisions

    (@mikevisions)

    Hi Bet,
    Thanks for the response.I understand what you are saying and that I am perhaps trying to do something that multisite is not designed to do. In your opion do you think it would be a more realistic idea to use a standard install with custon landing pages for each area site?

Viewing 9 replies - 1 through 9 (of 9 total)