Insert First Image into post (full-width)

This is the function I use, maybe there is a better way. $attachments = get_children( array( ‘numberposts’ => -1, ‘order’=> ‘ASC’, ‘post_mime_type’ => ‘image’, ‘post_parent’ => get_the_ID(), ‘post_type’ => ‘attachment’ )); $first_attachment = reset($attachments); //$last_attachment = end($attachments); or last image echo wp_get_attachment_image($first_attachment->ID, ‘full’); Additional wp_get_attachment_image parameters found here: http://codex.wordpress.org/Function_Reference/wp_get_attachment_image

How to: Simple Nested Shortcode [closed]

it looks like you have extra spaces in your shortcodes. Try [loggedin] [info_box type=”setting”]content text[/info_box] [/loggedin] instead of [loggedin] [ info_box type=”setting” ]content text[ /info_box] [/loggedin]

using shortcodes in theme content

To put shortcode within a PHP template, use do_shortcode(); <?php echo do_shortcode( ‘[like_to_read]The text that is hidden from the user.[/like_to_read]’ ); ?> Edit: <?php echo do_shortcode( ‘[like_to_read]’ . get_the_content() . ‘[/like_to_read]’ ); ?>

Filter Shortcodes when using get_page

If you want to display the shortcodes in the string variable $content you can use the WordPress function do_shortcode() like this: echo do_shortcode($content); See more in the Codex: http://codex.wordpress.org/Function_Reference/do_shortcode

Get variable value based on string constant

You can do that, but you shouldn’t: Keep the global namespace clean. Each name in the global namespace is a collision candidate. Making a variable global, a constant or a function increases the likelihood of a collision, no matter how good your prefixes are. Constants are the slowest global types. Yes, that’s micro-optimization, but why … Read more

Create Short code dynamically

I cannot comment, I would if I could, but I can’t, please don’t down-vote Could you not just use 1 shortcode with a parameter, e.g. instead of create one for each gallery image-gallery-1,image-gallery-2 etc, you could just use the ID as a parameter: image-gallery 1, image-gallery 2 … Then in your handling function you can … Read more

Custom Fields – Boolean Display of True/False to Yes/No

How about using a ternary operator? if ($immopress_property[‘assistedLiving’]): ?> <li class=”assistedLiving”> <span class=”attribute” style=”width:200px;display:block;float:left;”><?php echo ‘Seniorengerechtes Wohnen’ ; ?><span class=”wpp_colon”>:</span></span> <span class=”value”><?php echo get_post_meta($post->ID, ‘assistedLiving’ , true) ? ‘Ja’ : ‘Nein’; ?>&nbsp;</span> </li> <?php wp_reset_query(); ?> <?php endif; ?> Also, please, keep your presentation separate from your content by not using inline styles.