Tagged: , ,

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #650445

    How can I get the content of a text block in a custom portfolio layout to appear as the content in the RSS feed?

    I know I can place text in the “excerpt” and it will show in RSS but I’m using the exerpt field to display a subheading in the Masonry gallery. Also it would be difficult for a client to remember to place their copy in the excerpt field.

    #650668

    Hi darrylo,

    I’m not sure if that would be possible without heavy modifications but send us admin login details in private and we’ll have a look.

    Thanks,
    Rikard

    #650979
    #651892

    Hi,

    Thank you for using Enfold.

    Unfortunately, you can’t fetch the content of a specific text block inside the advance layout builder. Use the custom field instead. Add this in the functions.php file:

    function avia_add_images_to_rss_feed($content)
    {
    	global $post;
    	$contentmod = get_post_meta( $post->ID, 'customfieldname', true );
    	if ( $contentmod ) { $content = $contentmod; }
    	return $content;
    }
    
    add_filter('the_excerpt_rss', 'avia_add_images_to_rss_feed');
    add_filter('the_content_feed', 'avia_add_images_to_rss_feed');
    

    Create a new custom field called “customfieldname” or anything you want to call it.

    Best regards,
    Ismael

    #652223

    Thanks Ismael. How can I enable custom fields for Portfolio? (not available under screen options)

    #652428

    Hi,

    Add this code:

    //enable custom fields for portfolio items 
    add_filter( 'avf_portfolio_cpt_args', 'avf_portfolio_cpt_args_mod', 1 );
    function avf_portfolio_cpt_args_mod( $args ) {
    	$args['supports'][] = 'custom-fields';
    	return $args;
    }

    Best regards,
    Ismael

    #653147

    That works great but when I add a custom field the thumbnail disappears in the feed.
    Is there a way I can include the custom field and the thumbnail image in the RSS feed?

    I tried like this but it only shows one or the other not both:

    //add custom field – feed – to feed for portfolio
    function avia_add_images_to_rss_feed($content)
    {
    global $post;
    if ( has_post_thumbnail( $post->ID ) ){
    $content = ‘<p>’ . get_the_post_thumbnail( $post->ID, ‘medium’ ) . ‘</p>’ . get_the_excerpt();}

    $contentmod = get_post_meta( $post->ID, ‘feed’, true );
    if ( $contentmod ) { $content = $contentmod; }
    return $content;
    }

    add_filter(‘the_excerpt_rss’, ‘avia_add_images_to_rss_feed’);
    add_filter(‘the_content_feed’, ‘avia_add_images_to_rss_feed’);

    #654556

    Hi,

    Please try this instead:

    function avia_add_images_to_rss_feed($content)
    {
    	global $post;
    
    	$image = '' . get_the_post_thumbnail( $post->ID, 'medium' ) . '<br/>' . get_the_excerpt();
    	$contentmod = get_post_meta( $post->ID, 'feed', true );
    
    	if ( has_post_thumbnail( $post->ID ) || $contentmod ) {
    		$contentmod = !empty($contentmod) ? $contentmod : '';
    		$image = !empty($image) ? $image : '';
    		$content = $image . '<br/>' . $contentmod;
    	}
    
    	return $content;
    }
    
    add_filter('the_excerpt_rss', 'avia_add_images_to_rss_feed');
    add_filter('the_content_feed', 'avia_add_images_to_rss_feed');

    Best regards,
    Ismael

    #654953

    I’m getting a syntax error on this line:

    if ( has_post_thumbnail( $post->ID || $contentmod ) {

    #655055

    Hi!

    My bad. There’s a missing bracket:

    if ( has_post_thumbnail( $post->ID ) || $contentmod ) {
    

    Best regards,
    Ismael

    #655370

    Thank you Ismael – works perfectly

    #655610

    Hi,

    Great, glad you got it working :-)

    Thanks,
    Rikard

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.