Ask your WordPress questions! Pay money and get answers fast! (more info)

Displaying or Hiding Metadata on Page from WP Dashboard WordPress

  • REFUNDED

I have a custom post type called "Celeb". This CPT contains two Taxonomy terms as "Men" and "Women".Each Post has two metadata as "Name" and "Age". (Please take alook at attached image)
Now I would Like to add a "Visibility" checkbox to WordPress CPanel to enable or disabe displaying the "Age" metadata on the page based on the Terms.
For example I would like to Hide the Age for all post under the ONLY "Women" Taxonomy term when the checkbox has been checked or vice versa.Can you please let me know how I can do this?

Answers (1)

2013-07-24

Kyle answers:

Is that bottom image actually in your admin, or is that what you are trying to do?


Behseini comments:

Hi Kyle,

I just illustrate that image in Photoshop. That is actually what I would like to have!


Kyle comments:

Are you trying to show/hide the age for each post or for all men or women?


Behseini comments:

Actually it is based on each Taxonomy terms. So, I can say it will include all men(posts) or women


Kyle comments:

Okay, what you are describing then is actually Custom Taxonomy Meta, which isn't really supported. There is one solution out there: http://en.bainternet.info/2012/wordpress-taxonomies-extra-fields-the-easy-way which adds some extra functions so you can do this. From there you can add custom columns to that screen you have there to show the meta that is stored in your new fields. Once you've done all that to show or hide it on the front end you will need a filter: either filter the output in the template or your query to modify the results, based on that new taxonomy meta.

Hope this helps get you started!


Behseini comments:

Thanks Kyle , Ii already saw this article but I have problem with second part:
<em>Once you've done all that to show or hide it on the front end you will need a filter: either filter the output in the template or your query to modify the results, based on that new taxonomy meta.</em>


Kyle comments:

It probably needs to be an output filter,

Essentially, where ever it is displaying in your theme, or template etc. you need something like


$show_hide = get_tax_meta($term_id,'text_field_id');

if($show_hide == 'show') {

echo $age;

}


Do you know what I mean?


Behseini comments:

Well, to be honest! No!
I need to use this inside a custom loop so the if part make sense to me but how to use it in whole loop? I mean a loop to display Celeb Title, Name, and the "Age" if the check box has been checked!

Thanks again


Kyle comments:

That goes inside the loop


Behseini comments:

so can you let me know how? How I can loop and output the result based on the taxonomy terms like following image? Please be informed that the image actually contains two different pages for Men and Women taxonomies.


Behseini comments:

Example Pages