This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // put this code in the theme's functions.php file | |
| function trim_excerpt($text) { | |
| return rtrim($text,'[...]'); | |
| } | |
| add_filter('get_the_excerpt', 'trim_excerpt') | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // place this in your theme's function.php file | |
| function the_category_filter($thelist,$separator=' ') { | |
| if(!defined('WP_ADMIN')) { | |
| //list the category names to exclude | |
| $exclude = array('Some Category','Another Category','Blah Blah Blah'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Some custom styling examples | |
| /* category pagination */ | |
| .pagination { | |
| margin: 0 0 10px 0; padding: 10px 0; border-top: 1px solid #ccc; | |
| } | |
| .page-numbers { | |
| font-family:proxima-nova,Arial, Helvetica, sans-serif; | |
| font-weight: normal; | |
| font-size: 15px; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| LargeImage: | |
| http://ecx.images-amazon.com/images/I/41jK517l%2BBL.jpg | |
| MediumImage: (adds '._SL160_' to the LargeImage URL) | |
| http://ecx.images-amazon.com/images/I/41jK517l%2BBL._SL160_.jpg | |
| SmallImage: (adds '._SL75_' to the LargeImage URL) | |
| http://ecx.images-amazon.com/images/I/41jK517l%2BBL._SL75_.jpg |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php // show a random video from the last 10 posts in the video category | |
| $vidCount = rand(0, 9); | |
| $my_query = new WP_Query( | |
| array( | |
| "cat" => 11, | |
| "showposts" => 1, | |
| "offset" => $vidCount, | |
| "post__not_in" => array($post->ID) // exclude the current post from the list |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Display a list of the 10 most commented posts (WordPress) | |
| * @author Corey Brown https://github.com/coreyweb | |
| * @author Aaron Collegeman: https://github.com/collegeman | |
| * @author Joey Blake: https://github.com/joeyblake | |
| * | |
| * Rules: | |
| * - show a list of 10 posts | |
| * - published any time |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php /* | |
| Get a list of all pages on a site, by their template name. | |
| This is useful in determining which custom page templates are in use (and the reverse: which are not) | |
| source: Jorge Pedret | |
| http://jorgepedret.com/web-development/get-pages-by-template-name-in-wordpress/ | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Resize images dynamically using wp built in functions. | |
| * @author Victor Teixeira http://profiles.wordpress.org/vteixeira/ | |
| * @author Aaron Collegeman http://aaroncollegeman.com | |
| * @see http://core.trac.wordpress.org/ticket/15311 | |
| * | |
| * @coreyweb's note: I asked Aaron to simplify Victor's original by excluding | |
| * the lookup to see if the original image is big enough to render the newly sized image. | |
| * Our themes don't increase image sizes (ever), and if they did, they would |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Convert URL's with protocol prefix | |
| $tweet = ereg_replace("[a-zA-Z]+://([-]*[.]?[a-zA-Z0-9_/-?&%])*", "<a href=\"\\0\">\\0</a>", $tweet); | |
| //Convert URL with just www. | |
| $tweet = ereg_replace("(^| |\n)(www([-]*[.]?[a-zA-Z0-9_/-?&%])*)", "\\1<a href=\"http://\\2\">\\2</a>", $tweet); | |
| //Convert # hashtags | |
| $tweet = ereg_replace("(^| |\n)(\#([-]*[.]?[a-zA-Z0-9_/-?&%])*)", "\\1<a href=\"http://search.twitter.com/search?q=\\2\">\\2</a>", $tweet); | |
| $tweet = str_replace("/#", "/", $tweet); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Soundcloud has a shortcode for WordPress.com, | |
| // but it doesn't work on self-hosted WordPress sites. | |
| // To make the standard shortcode work, add this to your functions.php file. | |
| // Here is what Soundcloud's "WordPress Code" shortcode looks like: | |
| // [soundcloud url="http://api.soundcloud.com/tracks/95232600" params="" width=" 100%" height="166" iframe="true" /] | |
| function soundcloud( $atts, $url='' ) { | |
| extract(shortcode_atts(array( | |
| 'url' => 'http://', |