Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>How about if you simply use if / else statement like this:</p> <pre><code>&lt;span class="value"&gt;&lt;?php $assist=get_post_meta($post-&gt;ID, 'assistedLiving' , true); if ($assist=="") echo "keine Daten"; else if(strtolower($assist)=='true') echo "Ja"; else if(strtolower($assist)=='false') echo "Nein"; ?&gt;&amp;nbsp;&lt;/span&gt; </code></pre> <p><strong>Note:</strong></p> <p>For the code above to work,values for assistedLiving must use true/false and not 1 or 0.</p> <p><strong>Update</strong></p> <p>This is my first attempt at modifying shortcodes, so I'm not sure if it will work.</p> <p>I'm also not sure if this is what you need:) - I modified it in a way so that you can specify a parameter <strong>fieldname</strong> and when used it should show only that field.</p> <p>Change your shortcode function to this:</p> <pre><code>function immopress_fields_shortcode( $atts ) { $args = wp_parse_args( $atts, array ( 'echo' =&gt; FALSE, 'fieldname' =&gt; "" ) ); return immopress_the_fields( $args ); } add_shortcode( 'immopress_fields', 'immopress_fields_shortcode' ); </code></pre> <p>In function immopress_the_fields() after</p> <pre><code>foreach ( $fields as $key =&gt; $value) { </code></pre> <p>add this:</p> <pre><code>if ($fieldname!="")//only look for a field when it is used in the shortcode if ($fieldname!=$key)//skip until you find the value in the shortcode continue; </code></pre> <p>Not that this code is not efficient since $fields gets filled with all the fields all the time. Modified code is just a workaround.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload