0

I am trying to do something which I thought would be simple but I am at a loss. (I've googled, played with different code, etc.)

I have the following Custom Taxonomy Job Attributes.

I have two check box category terms(?):

  • paid
  • union

    1. I would like to display a taxonomy link for 'union' if union is selected.
    2. I would like to display a taxonomy link for 'union' if union AND paid is selected.

In other words, I would like to ignore that 'paid' is selected.

Breakdown:

  1. paid selected = display nothing.
  2. union selected = display taxonomy link 'union'.
  3. paid AND union are selected = display taxonomy link 'union'.

I am also trying to make this into a short code; I am integrating into something else:

function wpv_check_for_union_func() {

// Ive tried a bunch of thing and would appreciate some leads.

}

add_shortcode( 'wpv_check_for_union', 'wpv_check_for_union_func' );
  • You will have to show us some code to better understand what you're doing. – Alex Dumitru Sep 14 '13 at 11:18
0

Your logic looks to me like it boils down to "if union is selected, then echo a link to union, else do nothing." I think your description is much too complicated. It looks like you can effectively ignore paid completely.

function wpv_check_for_union_func($attr,$content='') {
  global $post;
  $taxonomy = 'yourtaxslug';

  $union = has_term('union', $taxonomy, $post);

  if ($union) {
    $term_link = get_term_link( 'union', $taxonomy );
    if( !is_wp_error( $term_link ) ) {
      return '<a href="' . $term_link . '">union</a>';
    }
  }

}

add_shortcode( 'wpv_check_for_union', 'wpv_check_for_union_func' );
  • Thank you so much! This is actually very close to what I was using but was not working. I was over thinking it a bit, and I wasn't thinking about using a 'if' statement which made the difference. Thank you again. – user1457514 Sep 14 '13 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.