3

I have added custom meta boxes in post and I want to put Tag slug name in the meta box text field, and want to display the text field's texts (Tag slug name) like following this.

<?php 
$my_query = new WP_Query( 'showposts=4&tag=' . $CUSTOM_META_BOX_ID_VALUE ); 

while ( $my_query->have_posts( )) : $my_query->the_post();  

//Post stuff.....  

endwhile; 
?>

Please can anybody help me?

I mean I'm trying to display related/recent posts by some specific tags for some specific posts. So I am trying it with Option Tree custom meta box code. Meta box register code is simply like this-

$my_meta_box = array(
'id'          => 'tsi_mp3_meta_box',
'title'       => __( 'Music Options', 'tsi' ),
'desc'        => '',
'pages'       => array( 'post' ),
'context'     => 'normal',
'priority'    => 'high',
'fields'      => array( 
 array(
'label'       => __( 'Tag Name <code>This is necessary for display Albums
contents & related posts</code>', 'tsi' ),
'id'          => 'tsitg',
'type'        => 'text',
'desc'        => __( 'Type the TAG name you added for this post.', 'tsi' )
  ),
)
);

And it appears like this in single post -

enter image description here

bangerz_miley_cyrus is the tag slug name of the post. And I want to display related posts under this tag in certain posts. So I want to add the value of 'tsitg' as tag slug name in WP_Query object something like this-

$my_query = new WP_Query( 'showposts=4&tag=' .$tsitg ); 
while ( $my_query->have_posts( )) : $my_query->the_post();  

So here I'm asking for help...

3
  • May you please elaborate? What does your custom metabox code look like? Commented Aug 25, 2016 at 19:47
  • The code you posted doesn't help us to understand your question or what you are trying to do. You posted a query loop but you want to display the tag slug?
    – bynicolas
    Commented Aug 25, 2016 at 19:57
  • I'm not sure you're using this correctly, could you edit your question ( by using the edit link above ) and expand upon what you're trying to do? Sounds like you need to use get_post_meta() or a meta_query instead but I'm unsure your goals.
    – Howdy_McGee
    Commented Aug 25, 2016 at 20:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.