How To Set Simple Embedding PDF Shortcode In WordPress
The following snippet will let you set simple embedding PDF shortcode in WordPress.
1 2 3 4 |
function viewpdf($attr, $url) { return '<iframe src="http://docs.google.com/viewer?url=' . $url . '&embedded=true" style="width:' .$attr['width']. '; height:' .$attr['height']. ';" frameborder="0">Your browser should support iFrame to view this PDF document</iframe>'; } add_shortcode('embedpdf', 'viewpdf'); |
Snippet Source/Credit: WPRecipes.com
Setting Up WordPress Post Expiration Code
The following snippet will let you set WordPress post expiration code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<?php //to check against expiration date; $timestamp = strtotime("now + 8 hours"); $currentdate = date('YmdHis', $timestamp); $expirationdate = get_post_custom_values('expiration'); if (is_null($expirationdate)) { $expirestring = '30005050235959'; //MAKE UN-EXPIRING POSTS ALWAYS SHOW UP; } else { if (is_array($expirationdate)) { $expirestringarray = implode($expirationdate); } $markup = array("/",":"," "); $expirestring = str_replace($markup,"",$expirestringarray); } //else if (( $expirestring > $currentdate ) || (is_archive())) { ?> <?php } //end if for expiration; ?> |
Snippet Source/Credit: nrbet.com
How To Delete Post From Front End In WordPress
Adding the following snippet will let you delete post from front end in WordPress.
1 2 3 4 5 6 7 8 |
<?php $url = get_bloginfo('url'); if (current_user_can('edit_post', $post->ID)){ echo '<a class="delete-post" href="'; echo wp_nonce_url("$url/wp-admin/post.php?action=trash&post=$id", 'delete-post_' . $post->ID); echo '">Delete post</a>'; } ?> |
Snippet Source/Credit: WordPress.org
How To Show Repeatable Region In WordPress Simple Fields Plugin
The following snippet will let you see repeatable region in WordPress simple fields plugin.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<?php $childPagesRepeatedGroup = simple_fields_get_post_group_values(get_the_id(),"Child Pages", true, 2); if ( isset($childPagesRepeatedGroup) && count($childPagesRepeatedGroup) > 0 ) { foreach ( $childPagesRepeatedGroup as $childPage ) { $imageSource = wp_get_attachment_image_src($childPage['Pic']); ?> <div class="child-links"> <img src="<?php print $imageSource[0]; ?>" width="<?php print $imageSource[1]; ?>" height="<?php print $imageSource[2]; ?>" /> <h2><?php print $childPage['Heading']; ?></h2> <p><?php print $childPage['Text']; ?></p> </div> <?php } ?> |
How To Fix UTF-8 Issues In WordPress
Adding the following lines of code will let you fix UTF-8 issues in WordPress.
Follow these steps:
1 |
http://codex.wordpress.org/Converting_Database_Character_Sets |
(see “Performing the actual conversion on your live database” section)
THEN install this plugin:
1 |
UTF8 Sanitize (http://wordpress.org/extend/plugins/wp-utf8-sanitize/) |
(fixes UTF8 encoding IN titles).
Snippet/Source Credit: Snipplr