Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * Render content for Relevanssi excerpt. This will load custom fields!
- */
- add_filter('relevanssi_excerpt_content', 'my_relevanssi_excerpt_content');
- function my_relevanssi_excerpt_content($content, $post = '', $query = ''){
- //Uncomment the following line if the custom fields belong to a single post-type. Increases performance!
- //if ( $post->post_type != 'my_post-type' ) return $content;
- //Fill in your custom field names here:
- $fields = array('myfield1', 'myfield1');
- foreach($fields as $field){
- //pay attention to $single (http://codex.wordpress.org/Function_Reference/get_post_meta)
- $field_value = get_post_meta($post->ID, $field, TRUE);
- $content .= ' '. ( is_array($field_value) ? implode(' ', $field_value) : $field_value );
- }
- return $content;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement