Skip Navigation

[Resolved] Shortcode in PHP

This support ticket is created 7 years, 5 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

Tagged: 

This topic contains 17 replies, has 3 voices.

Last updated by Bochnacki 7 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#530722

Dear Bochnacki,

Thanks for the details, I am checking it in your website, will feedback if there is anything found.

#530788

Here are what I found:
1) In the custom PHP codes you mentioned in the private message, it is a custom shortcode [wptypes_listvfav]

2) Create a content template "Shortcode in PHP", the content template ID is 1757
hidden link
It is only an example, you can add your custom shortcodes and HTML codes in it, design it as what you want.

3) In the theme/functions.php, , line 498~505, modify it from:

...
$content .= "<div class='ad favorites'>";
		$content .= "<div class='ad-thumb'><a href='".get_permalink($post_id)."'>". get_the_post_thumbnail ( $post_id ) ."</a></div>";
		$content .= "<div class='ad-data'><div class='ad-title'><a href='".get_permalink($post_id)."' title='".  $p->post_title ."'><h2>".$p->post_title."</h2></a></div><div class='ad-price'>". $favcena ."</div><div class='price-note'>". $opcjeceny ."</div><div class='ad-items'><div class='ad-items-left'><div class='ad-desc'>". $krotkiopis ."</div><div class='ad-item-milage'>". $przebieg ."</div>". $vendorstatus."<div class='ad-item-year'>". $rokprodukcji ."</div><div class='ad-item-fuel'>". $rodzajpaliwa ."</div><div class='ad-item-capacity'>". $pojemnoscsilnika ."</div><div class='ad-item-location'>". $lokalizacja ."</div></div><div class='ad-items-right'>
				<div class='ad-item-author'>
					<a href='<em><u>hidden link</u></em>;". $postauthor ."</a>
				</div>
			<div class='cont-form-pop popup'>";
		$content .= "</div><a class='ad-item-delete' href='?wpfpaction=remove&page=1&postid=$post_id'>Usuń z Ulubionych</a></div></div></div></div>";
...

To:

$content .= render_view_template(1757, $p);

As you can see, there just needs only one PHP line to render the content template.
More help:

4) Then test it in the front-end:
hidden link

More help:
https://toolset.com/documentation/programmer-reference/views-api/#render_view_template

#531098

Minesh and Luo Yang, great thanks for the help!

$content .= render_view_template(1757, $p);

this solved the problem 🙂