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 | |
| function search_by_post_and_meta_fields($args) { | |
| global $wpdb; | |
| $defaults = array( | |
| 'post_type' => 'post', | |
| 'post_fields_to_search' => false, | |
| 'meta_fields_to search' => false, | |
| 'search_term' => false | |
| ); | |
| extract(wp_parse_args($args, $defaults)); |
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 | |
| $args = array( | |
| 'post_type' => 'listing', | |
| 'post_fields_to_search' => array('post_title', 'post_content'), | |
| 'meta_fields_to_search' => array('_tags'), | |
| 'search_term' => 'hello' | |
| ); | |
| $post_ids = search_by_post_and_meta_fields($args); | |
| foreach($post_ids as $post_id) { | |
| $post = get_post($post_id); |
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 | |
| class post_search_meta { | |
| function post_search_meta() { | |
| add_filter( 'posts_where' , array( $this , 'where' ) ); | |
| add_filter( 'posts_join' , array( $this , 'join' ) ); | |
| add_filter( 'posts_groupby' , array( $this , 'group' ) ); | |
| } | |
| function group( $groupby ) { | |
| global $wp_query, $wpdb; | |
| if( empty($groupby) ) $groupby = "{$wpdb->posts}.ID"; |
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 | |
| function hash_djb2($str){ | |
| $hash = 5381; | |
| $length = strlen($str); | |
| for($i = 0; $i < $length; $i++) { | |
| $hash = ( ($hash << 5) + $hash ) + $str[$i]; | |
| } | |
| return ($hash & 0xFFFFFFFF); | |
| } |
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 the following code inside your single.php: | |
| include("related.class.php"); | |
| $related = new rs_related(); | |
| $postids = $related->get_related($post->ID,5); | |
| if( count($postids) ){ | |
| ?> | |
| <h3>Related posts:</h3> | |
| <ul> |
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 | |
| $limit = 5; | |
| $strictlimit = TRUE; | |
| $weight = array( | |
| 'body'=>1, | |
| 'title'=>1, | |
| 'tax'=>1 | |
| ); |
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 | |
| /* | |
| This is a simple, Laravel-like config sysytem, add files to a config/ folder in the following setup: | |
| config.php: | |
| <?php | |
| return array( | |
| 'site_name' => 'My Website', | |
| 'site_strapline' => 'This is my first website' | |
| ); |
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
| /*! normalize.css v3.0.1 | MIT License | git.io/normalize */ | |
| html { | |
| font-family: sans-serif; | |
| -ms-text-size-adjust: 100%; | |
| -webkit-text-size-adjust: 100%; | |
| } | |
| body { | |
| margin: 0; | |
| } | |
| article, |