Skip Navigation

[Resolved] Stylish the message according to the content template of page

This support ticket is created 4 years, 3 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 1 reply, has 2 voices.

Last updated by Waqar 4 years, 3 months ago.

Assisted by: Waqar.

Author
Posts
#1830635

Dear Sir/Madam,

I want to apply the Bootstrap 4 Alerts to all the prompt message if the content template is applied. How can I check the page is being applied content template?

I will add script at the end of the body content. I want to change for example

<div class="wp-success">

to

<div class="wp-success alert alert-success">

or

<div class="wp-error">

to

<div class="wp-error alert alert-danger">

Best regards,

Kelvin.

#1833211

Hi Kelvin,

Thank you for contacting us and I'd be happy to assist.

The ID of the assigned Toolset's content template is saved as a custom field value with a key "_views_template".

If your goal is to include some script in the footer of the page, only if a certain content template is assigned to it, you can use the "wp_footer" hook:
( ref: https://developer.wordpress.org/reference/hooks/wp_footer/ )


function your_function() {

	$template_id = do_shortcode('[wpv-post-field name="_views_template"]');

	if($template_id == 1234) {
		echo "<script>";
		// custom script
		echo "</script>";
	}

}
add_action( 'wp_footer', 'your_function' );

Please replace 1234 with the actual ID of the content template to check for.

regards,
Waqar