Created
February 20, 2012 18:13
-
-
Save remkus/1870417 to your computer and use it in GitHub Desktop.
Adding Custom Fields to Custom Post Type feed
This file contains 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 | |
add_filter( 'the_content_rss', 'iculture_add_custom_fields_to_apptopvijf_content' ); | |
add_filter( 'the_content', 'iculture_add_custom_fields_to_apptopvijf_content' ); | |
/** | |
* Alter the content output for the apptovijf custom post type. | |
* | |
* @global $post Post object | |
* @param string $content Existing content. | |
* @return string Filtered content. | |
* | |
*/ | |
function iculture_add_custom_fields_to_apptopvijf_content( $content ) { | |
global $post, $id; | |
// Skip filter if not CPT apptopvijf | |
if ( 'apptopvijf' != get_post_type( $post->ID ) ) | |
return $content; | |
// do filtering | |
$app_name = get_post_meta( $post->ID, '_iculture_app_naam', $single = true ); | |
$dev_name = get_post_meta( $post->ID, '_iculture_ontwikkelaar_naam', $single = true ); | |
$app_stars = get_post_meta( $post->ID, '_iculture_stars_app', $single = true ); | |
$price_app = get_post_meta( $post->ID, '_iculture_prijs_app', $single = true ); | |
$uni_app = get_post_meta( $post->ID, '_iculture_uni_app', $single = true ); | |
$app_link = get_post_meta( $post->ID, '_iculture_app_link', $single = true ); | |
$app_icon = get_post_meta( $post->ID, '_iculture_app_icon', $single = true ); | |
$content = '<p class="app-naam">'. $app_name .'</p> | |
<p class="dev-naam">'. $dev_name .'</p> | |
<p class="dev-naam">'. $app_stars .'</p> | |
<p class="dev-naam">'. $price_app .'</p> | |
<p class="dev-naam">'. $uni_app .'</p> | |
<p class="dev-naam">'. $app_link .'</p> | |
<p class="dev-naam">'. $app_icon .'</p>' . $content; | |
return $content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment