Skip Navigation

[Resuelto] shortcodes inside template stops displaying after update to 4.2.3/4.2.4

This support ticket is created hace 7 años, 6 meses. 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 3 respuestas, has 2 mensajes.

Last updated by jsono hace 7 años, 6 meses.

Assigned support staff: Minesh.

Autor
Mensajes
#323770
Screenshot 2015-08-09 14.43.00.png
Screenshot 2015-08-09 14.42.38.png
Screenshot 2015-08-09 14.42.07.png

I am trying to:
Correct shortcodes that was previously display and now stops after updates.
I visited this URL:

I expected to see: ratings to display.

Instead, I got: blank on ratings elements.

I have [rating-average] shortcodes inside a template and display that template inside another template which uses to be display rating average. It was working just fine until I updated to WP 4.2.3 and all toolset to current version. It stops displaying rating average (see screenshots).

Here’s a detail...

I have [rating-average] shortcodes placed inside a template called [wpv-post-body view_template="display-overall-rating"] and place that display-overall-rating template inside another template called restaurants-details-single to display average rating for particular listing. Now since updating to latest WP and all toolsets to current version it stops display average rating.

I’ve been follow that there’s many issue relating to shortcodes and I appreciate toolset team hard work on this issues. 🙂
reference: https://toolset.com/forums/topic/wordpress-4-2-3-update-breaks-shortcodes/

Here’s my codes

Rating Average Shortcode

add_shortcode('rating-average', 'rating_average_func');
function rating_average_func()
{
    global $post;
    $args = array(
       'post_type' => 'reviews',
        'meta_key' => '_wpcf_belongs_' . $post->post_type . '_id',
        'meta_value' => $post->ID,
    );
    $child_posts = get_posts($args);
           
    $sum = 0;
    $num = 0;
    foreach ($child_posts as $child_post) {
        $ratings = get_post_meta($child_post->ID, 'wpcf-ratings', true);
        if($ratings)
        {
            $sum += $ratings;
            $num ++;
        }
    }
    $average = 0;
    if($num>0)
    {
        $average = $sum/$num;
    }
    $res = $average;
    if($average==0) $res = 0;
    if($average>0.001 && $average<0.5)$res = 0.5;
    if($average>0.501 && $average<1) $res = 1;
    if($average>1.001 && $average<1.5) $res = 1.5;
    if($average>1.501 && $average<2) $res = 2;
    if($average>2.001 && $average<2.5) $res = 2.5;
    if($average>2.501 && $average<3) $res = 3;
    if($average>3.001 && $average<3.5) $res = 3.5;
    if($average>3.501 && $average<4) $res = 4;
    if($average>4.001 && $average<4.5) $res = 4.5;
    if($average>4.501 && $average<5) $res = 5;
//... here put more condition ...
    return $res;
}

Display Overall Rating Template


<div class="avg-rating fa stars-[rating-average]">
<div class="rating-box"> 
<span itemprop="aggregateRating" itemscope itemtype="<em><u>hidden link</u></em>">
<meta itemprop="ratingValue" content="Rated [rating-average] out of [reviews_total]"> from <span itemprop="ratingCount">[reviews_total]</span> reviews.
 </span></div>
</div>

Restaurants Details Single


<!---TOP FULL WIDTH-->

<div>

    <div>
      <h3>[wpv-post-title]</h3>
  [wpv-post-body view_template="Overall Rating"]
    </div>
    
</div>

<!---CONTACTS & MAPS-->
<div>
	
  <div>
    [wpv-post-body view_template="map-content-single-post"]
    [wpv-post-body view_template="business-address"]  
    Cuisine: [wpv-post-taxonomy type="cuisines"]
    Category: [wpv-post-taxonomy type="restaurant-category"]
    Serving Options: [wpv-post-taxonomy type="dining-options"]
    </div>
    <div>
      <div>
      [wpv-post-body view_template="contact-details"]     
      </div>
      <div>[wpv-view name="Flex slider - main slider"]</div>
      <div>[wpv-view name="Flex slider nav - thumbnails"]</div>
      
    </div>

</div>
<!---MORE RATINGS-->
<div>

  <div>
    [wpv-post-body view_template="More Ratings"]
    </div>

</div>
<!---FEAURES-->
<div>

  <div>
      [wpv-post-body view_template="restaurant-features-list"]
    </div>

</div>

I’ll provide login credential in another reply.

#323881

Minesh
Supporter

Languages: Inglés (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello and thank you for contacting Toolset support.

*** Please take FULL BACKUP of your database and your website.***
In order to investigate your issue if we require to check things on your install in order to see what could be going wrong there.

If you agree to this please use the form fields I have enabled below this comment box to provide temporary access details (wp-admin and FTP)?

I have set next reply as private.

#324265

Minesh
Supporter

Languages: Inglés (English )

Timezone: Asia/Kolkata (GMT+05:30)

Could you please check now, I can see your ratings on the page.
=> hidden link

With current version of views, shortcode placed inside any html tag attribute is not inner-parsed by Views so the native usage for it will not work when inside tags or conditionals.

The good news is that this issue is known to us and its already been fixed and it will be supported by Views next release version Views v1.10, that will be release in the near-future. I can't commit to a date yet but it's already in the works.

But to resolve your issue there is a workaround within the plugin itself.
Go to:
=> Views > Settings > Compatibility
=> In the section named "Third-party shortcode arguments" add all the shortcodes which you have used inside html tag attribute. I've already done it for you.

Once we release views next version v1.10 you should update your plugin to same and your issue will be automatically fixed.

#324281

Thanks @minesh 🙂

I see how it works now and hope toolset team relase the update soon.

You and Toolset team are awesome.

Cheers,
Json