Skip Navigation

[Resolved] Shortcode within Shortcode not working

This support ticket is created 6 years, 12 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 8 replies, has 3 voices.

Last updated by Christian Cox 6 years, 11 months ago.

Assisted by: Christian Cox.

Author
Posts
#594461

I am using the FaceBook Feed Pro by Smashballoon on hidden link.

I have been using it on this site for years with out an issue.

Smashballoon has a shortcode that basically is something like this...

[custom-facebook-feed id='XXXXXXXXXXXXXXXXX'] where the id is the Facebook id of the entities I want to show the feed for.

The plugin allows multiple ids, so I created a view to list all of the ids.

The resulting Shortcode is this....
[custom-facebook-feed id='1565045343719930[wpv-view name="include-comma-separated-facebook-ids-for-events" raw="true" no-view-wrap="true"]' type=events eventsource=eventspage  num=99 limit=99 layout=thumb desclength=200 eventimage=cropped include='media,link,author,eventtitle,eventdetails,date' eventdatepos=above eventdatecustom='l, F j (g:ia)']

If I simply display the view by itself, the resulting output is...

,Eaglesnestrockincountrybar,1434861936743073,408000962864570,884982521647749,1565045343719930,190266227682064,509469945744482,55338077653,219191728177198

(which is all of the id numbers that I want to use for the feed)

Therefore the entire shortcode should be...
[custom-facebook-feed id='1565045343719930,Eaglesnestrockincountrybar,1434861936743073,408000962864570,884982521647749,1565045343719930,190266227682064,509469945744482,55338077653,219191728177198' type=events eventsource=eventspage  num=99 limit=99 layout=thumb desclength=200 eventimage=cropped include='media,link,author,eventtitle,eventdetails,date' eventdatepos=above eventdatecustom='l, F j (g:ia)']

However it is not working. The result used to work just fine. If I remove the WP-TYPES shortcode and simply add the id number manually, it works. I cannot determine if this is an issue with WP-Types or Smashballoon.

You can actually see the current result at the bottom of this page...
hidden link

#594478

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ned,

Thank you for contacting our support forum.

You are saying that this use to work where you add of views shortcode to pass the information to the shortcode ?

Please let me know.

Thanks,
Shane

#594503

Yes, this complete shortcode used to work....

[custom-facebook-feed id='1565045343719930[wpv-view name="include-comma-separated-facebook-ids-for-events" raw="true" no-view-wrap="true"]' type=events eventsource=eventspage num=99 limit=99 layout=thumb desclength=200 eventimage=cropped include='media,link,author,eventtitle,eventdetails,date' eventdatepos=above eventdatecustom='l, F j (g:ia)']

It used to produce the correct Facebook Feed. Now it doesn't work at all. It simply displays "broken" shortcode text.

#594519

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Ned,

Could you try adding this to your functions.php file and let me know if it helps

add_filter( 'wpv_filter_wpv_view_shortcode_output', 'prefix_clean_view_output', 5, 2 );

function prefix_clean_view_output( $out, $id ) {
if ( $id == '375' ) {
$start = strpos( $out, '<!-- wpv-loop-start -->' );
if ( 
$start !== false
&& strrpos( $out, '<!-- wpv-loop-end -->', $start ) !== false
) {
$start = $start + strlen( '<!-- wpv-loop-start -->' );
$out = substr( $out , $start );
$end = strrpos( $out, '<!-- wpv-loop-end -->' );
$out = substr( $out, 0, $end );
}
}
return $out;
}

You will need to change the 375 to the ID of your view.

Please let me know if this helps.
Thanks,
Shane

#594554

That did not work. The output result has changed.... but now all it seems to do is negate any results at all from the Facebook feed shortcode.

In other words... instead of showing the Facebook events (which is what i am looking for) it simply says... "No Events Found"...

Which is not correct.

There are DEFINITELY existing Facebook events, becaue if I copy/paste the actual comma separated ID numbers into the shortcode, it works fine

#594555

BTW: I removed your custom function after seeing the results

#594604

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Neg,

The best explanation I can give for this is that views is not meant to be a content provider for another plugin but is meant to display its own content, hence why there are wrapper classes around the view.

The function that i provided was to remove these wrapper classes. If the shortcode doesn't even after removing the wrapper classes then there isn't much I can do here.

What I can do is to check to see if the function is removing the classes and providing a clean output from views that your shortcode should detect. The issue could also be on your shortcodes end as well .

Would you mind providing me with admin access so that I can run some checks on the site ?

The private fields will be enabled for your next response.

Thanks,
Shane

#594664

I have found the issue....

As you can see in my post above, the inner WP-TYPES shortcode that I inserted into my page was...

[wpv-view name="include-comma-separated-facebook-ids-for-events" raw="true" no-view-wrap="true"]

Notice the.... (no-view-wrap="true")... at the end of the shortcode.

This was added to the shortcode in a attempt to do what you were trying to do.... which is provide a "clean" output for the view. The (no-view-wrap="true") attribute was inserted a long time ago based on this Support Thread from TheWebists....

https://toolset.com/forums/topic/disabling-new-view-wrapper-div-in-views-1-11/

I checked my custom function file and I could no longer find that custom function provided by that thread. Not sure where it disappeared to. I tried re-adding the custom function and it broke my site... so it looks like that custom function no longer works as a solution to providing "clean" output.

So I used your custom function. I removed the..... if ( $id == 'XXXXXX' ) { }....... qualifier and allowed it to provide clean output for ALL VIEWS. It seems to work now. Probably not a good idea though.

I would prefer to try and get the code from TheWebists working again. I use the shortcode attribute (no-view-wrap="true") in many places throughout my site.

Can you provide an updated code based on the solution found here...

https://toolset.com/forums/topic/disabling-new-view-wrapper-div-in-views-1-11/

#594873

Hi, Shane is off for a few days so I've been asked to look after this ticket in his absence. I hope that's okay with you.

I would prefer to try and get the code from TheWebists working again. I use the shortcode attribute (no-view-wrap="true") in many places throughout my site.
Actually 'no-view-wrap' is not a documented attribute, it's custom code added by another Toolset user. Here in the forums, we do not support the use of undocumented attributes in custom code. Please find the attributes we support in the documentation here:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-view

The best solution for now is to use the code provided by Shane to "unwrap" the output of each View. If you need to apply this filter to multiple Views, you can modify it to use a comma-separated list of View IDs. I have a sample here you can reuse:

add_filter( 'wpv_filter_wpv_view_shortcode_output', 'prefix_clean_view_output', 5, 2 );

function prefix_clean_view_output( $out, $id ) {
  $ids = array( 1, 2, 3, 4 );
  if ( in_array( $id, $ids )) {
    $start = strpos( $out, '<!-- wpv-loop-start -->' );
    if (
      $start !== false
      && strrpos( $out, '<!-- wpv-loop-end -->', $start ) !== false
    ) {
      $start = $start + strlen( '<!-- wpv-loop-start -->' );
      $out = substr( $out , $start );
      $end = strrpos( $out, '<!-- wpv-loop-end -->' );
      $out = substr( $out, 0, $end );
    } else {
      $start = strpos( $out, '>' );
      if ( $start !== false) {
        $out = substr( $out, $start + 1 );
        $end = strpos( $out, '<' );
        $out = trim(substr( $out, 0, $end ));
      }
    }
  }
  return $out;
}

Replace 1,2,3,4 with a comma-separated list of numeric View IDs from which you want to strip out the extra wrapper markup. You can find the numeric View IDs by going to Toolset > Views in wp-admin.