Skip Navigation

[Resolved] Displaying formatted data instead of raw data

This support ticket is created 5 years, 11 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
- 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/Karachi (GMT+05:00)

This topic contains 9 replies, has 3 voices.

Last updated by jelle-jacobd 5 years, 10 months ago.

Assisted by: Waqar.

Author
Posts
#1171718

Tell us what you are trying to do?
In a test view with a loop I'm using: [wpv-post-field name="attribute_pa_beam-angle"] this works and shows the raw output, but if want formatted data I should use [wpv-post-taxonomy type="pa_beam-angle"] but htis doesn't show any value(s) on the front-end?

#1172070

Hi, the wpv-post-field shortcode is used to access the raw value of a custom field in a post. To display formatted data, you should use the types field shortcode, as documented here:
https://toolset.com/documentation/customizing-sites-using-php/functions/

Click the orange "More info" buttons to display examples of post fields, term fields, and User fields. You can find information about PHP implementations as well.

#1172290

Hi Christian,

Thanks. looks like I can't use [wpv-post-taxonomy type="my-taxonomy"] in a filtered loop and that I should use a custom shortcode to get the result I need. For now I can only use: [wpv-post-field name="my-taxonomy"]. This outputs the raw data or slug, but I need the name of the taxanomy and value.

I'm not sure how to achieve this correctly.. can you help me a little. I need to do this for 20 similar attributes on the same page, which I could replicate myself? Thanks.

#1173390

Hi there,

Thank you for waiting and I'll be happy to follow up on this thread, while Christian is on holidays.

The "wpv-post-taxonomy" shortcode is very flexible and using its "format" attribute, you can either return attached taxonomy's HTML link, url, name, description, slug or count:
https://toolset.com/documentation/user-guides/views-shortcodes/#vf-153472

In case this specific shortcode is not bringing in data from the attached terms as expected, you're welcome to share temporary admin login details so that I can troubleshoot this in more detail. Please also share a link to the page where the test view can be seen.

Your next reply will be private so that only you and our support team will have access to it.

Important note: Please make a complete backup copy of the website, before sharing the access details.

regards,
Waqar

#1174069

Thanks for sharing further details and access to the admin area.

To show the formatted names from different product attributes, you can first register a new custom shortcode, by adding the following code to your active theme's "functions.php" file:


add_shortcode( 'show-product-attribute', 'show_product_attribute_func');
function show_product_attribute_func($atts){
	$attribute = $atts['attribute'];
	
	if ( !empty($attribute) ) {

		global $product;

		$value = $product->get_attribute( $attribute );
		
		if (!empty($value)) {
			return $value;
		}
	}
}

After that, to get the formatted attribute value, you can use the shortcode like this:


[show-product-attribute attribute="pa_beam-angle"]

Feel free to replace the attribute value with other term slugs too.

I hope this helps!

regards,
Waqar

#1174183

Hi Waqar,

Thanks a lot!!! I would like to now how to learn to create these kind of shortcodes myself, is there a step-by-step tutorial available somewhere?

Thanks.

#1174284

Hi Waqar,

One last question, how can I hide the label (pleas see the screenshot) that's placed there automatically by shortcode: [wpv-woo-product-meta]

<img src="hidden link" alt="Image from Gyazo" width="510"/>

I tried to do this with css, but no luck so far.

Related page link: hidden link

#1175083

Hi,

Thanks for the update.

Following are some useful links for learning about the custom shortcodes:
https://codex.wordpress.org/Shortcode_API
hidden link
https://toolset.com/documentation/adding-custom-code/how-to-create-a-custom-shortcode/

To hide the label "SKU", you can add the following custom CSS code into your view's "CSS editor" tab:


.product_meta .sku_wrapper {
	font-size: 0px !important;
	line-height: 0px !important;
}

.product_meta .sku_wrapper .sku {
	font-size: 16px !important;
	line-height: 27px !important;
}

I hope this helps and for a new/different question or concern, you're welcome to open a new ticket.

Happy New Year,
Waqar

#1175144

My issue is resolved now. Thank you!

Happy new year!!

#1178503
Schermafdruk 2019-01-06 14.21.38.png

Hi Waqar,

The CSS snippet works very nice in a screen css. But in a print style sheet or PDF it looks like this. How can I solve this issue?
SKU is suddenly very large.

Please click on the following link and choose for print/pdf and create a PDF to replicate the issue.

hidden link

Thanks.