How and when to include shortcode source files

The pattern I use is: break code into modules using classes use spl_autoload_register() to load classes (thereby only included when used) have a class that is the plugin controller, with a method for each shortcode those methods generally do nothing but create instance of shortcode class and pass params Works for me, simplifies things greatly, … Read more

Clearfix Shortcode

Here’s the code to be added to functions.php. As a bonus I’ve included a shortcode for a horizontal rule <hr>: function shortcode_hr() { return ‘<hr>’; } function shortcode_clearfix() { return ‘<div style=”display: block; visibility: hidden; clear: both; height: 0;”></div>’; } function register_shortcodes() { add_shortcode(‘hr’, ‘shortcode_hr’); add_shortcode(‘clearfix’, ‘shortcode_clearfix’); } add_action( ‘init’, ‘register_shortcodes’); Nothing complicated here, so … Read more

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]’ ); ?>

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.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)