Using the following snippet, you will be able to add a logo to a template.
1 | <img src="<?php echo get_stylesheet_directory_uri()?>/images/logo.png" alt="My Logo"> |
Snippet Source/Credit: WPSnipp
By Editorial Staff in WordPress No Comments Tags: Code, Code Snippet, Snippet, WordPress, WordPress Snippet, WordPress Snippets
Using the following snippet, you will be able to add a logo to a template.
1 | <img src="<?php echo get_stylesheet_directory_uri()?>/images/logo.png" alt="My Logo"> |
Snippet Source/Credit: WPSnipp
By Editorial Staff in WordPress No Comments Tags: Code, Code Snippet, Snippet, WordPress, WordPress Snippet, WordPress Snippets
The following snippet will let you use WordPress shortcodes in theme files.
1 | <?php echo do_shortcode("[your_shortcode]"); ?> |
By Editorial Staff in WordPress No Comments Tags: Code, Code Snippet, Snippet, WordPress, WordPress Snippet, WordPress Snippets
Using the following snippet, you will be able to add Pinterest button in WordPress.
Add to your header above the body tag
1 | <script type="text/javascript" src="http://assets.pinterest.com/js/pinit.js"></script> |
Edit and add to your page where you want your button to appear.
1 | <div class="socialIcon-box"><a href="http://pinterest.com/pin/create/button/?url=http%3A%2F%2Fyourdomain.com&media=<?php bloginfo(template_directory); ?>/images/youricon.png&description=Site%20Name%20and%20Description" class="pin-it-button" count-layout="horizontal"><img src="<?php bloginfo(template_directory); ?>/images/youricon.png" /></a></div> |
Snippet Source/Credit: flashalexander.com
By Editorial Staff in Featured, WordPress No Comments Tags: Code, Code Snippet, Snippet, WordPress, WordPress Snippet, WordPress Snippets
The following snippets will let you showcase content to logged-in users.
1 2 3 4 5 6 7 8 9 10 | <?php add_shortcode("hide","hide_shortcode"); function hide_shortcode($x,$text=null){ if(!is_user_logged_in()){ return "You have to been registered and logged in to see this content"; }else{ return do_shortcode($text); } } ?> |
Snippet Source/Credit: Snipplr
By Editorial Staff in Featured, WordPress No Comments Tags: Code, Code Snippet, Snippet, WordPress, WordPress Snippet
The following lines of code will let you check PHP version of your WordPress website.
1 2 3 4 5 | <?php if ( version_compare(PHP_VERSION, '5.2.4', '<') ) { wp_die('PHP 5.2.4 is required.'); }; ?> |
Snippet Source/Credit: PHP.net
By Editorial Staff in Featured, WordPress No Comments Tags: Code, Code Snippet, Snippet, WordPress, WordPress Snippet, WordPress Snippets
Adding the following snippet to your theme’s functions.php file, you will be able to set a maximum word count on post titles.
1 2 3 4 5 6 7 | function maxWord($title){ global $post; $title = $post->post_title; if (str_word_count($title) >= 10 ) //set this to the maximum number of words wp_die( __('Error: your post title is over the maximum word count.') ); } add_action('publish_post', 'maxWord'); |
Snippet Source/Credit: Pippin
By Editorial Staff in WordPress No Comments Tags: Code, Code Snippet, Snippet, WordPress, WordPress Snippet, WordPress Snippets
Use the snippet below and you are able to change the font as per your wish.
1 2 3 4 5 | add_action( 'admin_head-post.php', 'devpress_fix_html_editor_font' ); add_action( 'admin_head-post-new.php', 'devpress_fix_html_editor_font' ); function devpress_fix_html_editor_font() { ?> <style type="text/css">#editorcontainer #content, #wp_mce_fullscreen { font-family: Georgia, "Times New Roman", "Bitstream Charter", Times, serif; }</style> <?php } |
Snippet Source/Credit: DevPress
By Editorial Staff in WordPress No Comments Tags: Code, Code Snippet, Snippet, WordPress, WordPress Snippet, WordPress Snippets
Using the following snippet, you will be able to add a logo to a template.
1 | <img src="<?php echo get_stylesheet_directory_uri()?>/images/logo.png" alt="My Logo"> |
Snippet Source/Credit: WPSnipp
By Editorial Staff in WordPress No Comments Tags: Code, Code Snippet, Snippet, WordPress, WordPress Snippet
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
By Editorial Staff in WordPress No Comments Tags: Code, Code Snippet, Snippet, WordPress, WordPress Snippet
The following snippet will let you detect users from Twitter in WordPress.
1 2 3 4 5 | <?php if (strpos($_SERVER[HTTP_REFERER], "twitter.com") == true) { echo "Hello Twitter User!"; } ?> |
Snippet Source/Credit: WP-Snippets.com