Tagged: Avia Layout, rss, seo
-
AuthorPosts
-
June 19, 2016 at 6:20 pm #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.
June 20, 2016 at 8:05 am #650668Hi 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,
RikardJune 20, 2016 at 6:06 pm #650979June 22, 2016 at 5:54 am #651892Hi,
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,
IsmaelJune 22, 2016 at 4:34 pm #652223Thanks Ismael. How can I enable custom fields for Portfolio? (not available under screen options)
June 23, 2016 at 3:40 am #652428Hi,
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,
IsmaelJune 24, 2016 at 7:11 pm #653147That 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’);June 29, 2016 at 3:53 am #654556Hi,
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,
IsmaelJune 29, 2016 at 6:10 pm #654953I’m getting a syntax error on this line:
if ( has_post_thumbnail( $post->ID || $contentmod ) {
June 30, 2016 at 3:56 am #655055Hi!
My bad. There’s a missing bracket:
if ( has_post_thumbnail( $post->ID ) || $contentmod ) {
Best regards,
IsmaelJune 30, 2016 at 4:35 pm #655370Thank you Ismael – works perfectly
July 1, 2016 at 9:48 am #655610 -
AuthorPosts
- You must be logged in to reply to this topic.