• Resolved glinch

    (@glinch)


    Hi

    As per the title. There are elements of content that are created by shortcodes (for descriptions).

    This isn’t created, as expected, in the feeds – what is returned is the shortcode itself.

    Is this a limitation of the plugin?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author AukeJomm

    (@aukejomm)

    Hello @glinch,

    We do not support shortcodes in the plugin because the attribute data needs to be clean. There are a lot of shortcodes out there and some will insert html etc what will make the product feed a mess.

    So we only add to the fields what is in the database.
    We do have a filter you can use to alter feed data and use that to strip shortcodes

    <?php
    
    function alter_feed_item( $attributes, $feed_id, $product_id ) {
    
    	// The $attributes variable is an array that contains all the product data that goes into the feed. Each item
    	// can be accessed by it's feed key. So if in the feed file an item has a key like 'description', you
    	// can access that specific item by $attributes['description'].
    	// The $feed_id (string) makes it possible to only edit a specific feed. You can find the id of a feed in the
    	// url of the Feed Editor, right after id=.
    	// The $product_id (string) makes it possible to select a specific product id that you want to filter.
    	
    	// The following example only changes the data of a feed with ID 7
    	if( $feed_id === '7' ) {
    		
    		// this line changes the title data and removes the " <prompt> " string
    		$attributes['title'] = str_replace( " <prompt> ", "", $attributes['title'] );
    		
    		// this lines puts the text Dollar behind the price data
    		$attributes['price'] = $attributes['price'] . " Dollar";
    		
    		// And you can be more specific by using the $product_id
    		if ( $product_id === '13' ) {
    			$attributes['availability'] = 'unknown';
    		}
    	}
    	
    	// or you can just make a simple change that will influence all feeds
    	// If you have shortcodes in your product description you can remove them with het next code
    	// Remove WordPress shortcodes from Description
    	$attributes['description'] = strip_shortcodes( $attributes['description'] );
    	
    	// If you use VIdual Composer markup in your product descrioptions you can remove Visual Composer markup with the next code.
    	$attributes['description'] = preg_replace("~(?:\[/?)[^/\]]+/?\]~s", '', $attributes['description'] );
    	
    	// IMPORTANT! Always return the $attributes
    	return $attributes;
    }
    
    add_filter( 'wppfm_feed_item_value', 'alter_feed_item', 10, 3 );

    Read more on github: https://gist.github.com/Auke1810/c62bb043926f539f9a99b418c06a3e6e

    Thread Starter glinch

    (@glinch)

    Hi Auke

    Thanks for getting back to me. It was pretty critical for the site to parse the shortcode as this generates custom content for a product.

    With a little bit of digging, some custom functions, and using the above filter I was able to extract and parse the shortcode to generate the content for $attributes[‘description’]

    Appreciate all your help on the matter.

    Cheers

    Noel

    • This reply was modified 6 years, 6 months ago by glinch.
    • This reply was modified 6 years, 6 months ago by glinch.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Content created by a shortcode is not created in the feeds’ is closed to new replies.