Skip Navigation

[Resolved] Content template is not overriding SmartMag theme

This support ticket is created 6 years, 1 month 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 4 replies, has 2 voices.

Last updated by Beda 6 years, 1 month ago.

Assisted by: Beda.

Author
Posts
#1120981

I have created a layout for a custom post type. But the front-end only displays the content with the theme's display. I think that there is no the_content() function in single.php that Toolset can override, but how can I sort that?

This is the relevant code in single.php that displays the content that I want to override:

<?php while (have_posts()) : the_post(); ?>

<?php
$panels = get_post_meta(get_the_ID(), 'panels_data', true);

if (!empty($panels) && !empty($panels['grid'])):

get_template_part('content', 'builder');

else:

get_template_part($partial, 'single');

endif;
?>

See for example hidden link

#1121338

The theme uses get_template_part which is a WordPress native function.
https://developer.wordpress.org/reference/functions/get_template_part/
It allows calling a specific PHP file that determines how the content is shown, hence that is where you would look for the "real" content display function (if any).

There is an easier way, you can head to Toolset > Settings > Front-end Content > Theme support for Content Templates.
https://toolset.com/documentation/user-guides/theme-support-for-content-templates/

If that does not work, you would have to create a child theme and in there, call the_content()

#1121352

Thanks. I tried the Theme support for Content Templates. The debugging output I get is "Bunyad_Posts::the_content, WP_Hook::apply_filters". If I simply copy all of that and add to box and save, the output on the Events post type page is still from the general theme.

I do have a child theme. Should I simply copy single.php and change that to use the_content() ? I tried it briefly on the main theme, but it output the entire HTML code, although I didn't look at it more carefully.

#1121536

To create a child theme and alter its template you can follow this guide:
https://codex.wordpress.org/Child_Themes

Your theme will require a child theme since the method of using the inbuilt compatibility for Content Templates will only work if your theme has a proper dedicated function to display the content.
Views will not accept generic PHP functions or auxiliar WordPress functions like:
require, require_once, include, include_once, locate_template, load_template, apply_filters, call_user_func_array.

You will need to create a Child theme according to above DOC and then replace all the files where you want to use Toolset with the content (and content is used/displayed).
Your theme makes usage of get_template_part() which is already made for Child themes usage, it allows you to modify the templates called.

#1121537

changing state