Custom Fields
Re-Envisioned
Support General Display Taxonomy Link from metabox

This topic contains 1 reply, has 2 voices, and was last updated by  Anh Tran 4 days, 5 hours ago.

  • Creator
    Topic
  • #13268

    Vee Jay
    Participant

    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
    Replies
  • #13289

    Anh Tran
    Keymaster

    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' );

    Or:

    $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.