Custom Fields
Support General Display Taxonomy Link from metabox

  • Creator
  • #13268
    Vee Jay

    I followed the documentation and was able to create several custom post types, custom taxonomies and to add metaboxes to my post type.

    One of the field i'm using is taxonomy.
    I'm able to display the taxonomy on my post, but it doesn't link to anything.

    Here's my code:

    $ptf = rwmb_meta( 'pub_type_field' );
    echo $ptf->name;

    What would be the normal way to display both the name of the taxonomy and the link to the archive page of the said tax? Thanks

Viewing 1 replies (of 1 total)
  • Author
  • #13289
    Anh Tran

    Hi Vee Jay,

    The rwmb_meta returns a term object, so if you echo $ptf->name, you output only its name.

    It's better to use:

    rwmb_the_value( 'pub_type_field' );


    $ptf = rwmb_meta( 'pub_type_field' );
    printf( '<a href="%s">%s</a>', get_term_link( $ptf ), $ptf->name );
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.