Skip Navigation

[Gelöst] Content Template repeating on page

This support ticket is created vor 5 Jahre, 9 Monate. 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 7 Antworten, has 2 Stimmen.

Last updated by jasonH-4 vor 5 Jahre, 9 Monate.

Assisted by: Nigel.

Author
Artikel
#911598
Content-Template-screenshot.jpg

I have some pages on my website where I pull in another page in WordPress in order to create a super-wide gallery on the page. The code is basically like this example:

global $post;
if ($post && $post->ID == 18149) {
echo do_shortcode('[wpv-post-body id="18148"]');
}

My problem is now that I have a content template set up for 18149, and it's now repeating on the part of the page that displays 18148.

I have had this setup for a number of years and it never behaved this way before. I'm not sure when it changed but it now displays my content places in two places on the page, the part that is 18149 and 18148, even though the content template is only enabled on page 18149.

I hope this makes sense. Thanks!

#911762

Nigel
Supporter

Languages: Englisch (English ) Spanisch (Español )

Timezone: Europe/London (GMT+00:00)

Hi Jason

There shouldn't in principle be a problem adding one content template inside another (either within the GUI, or in PHP as you are doing), unless you risk creating an infinite loop by nesting the same template inside itself.

It would be easiest if I could take a quick look at your site to double-check how you have this set up for myself, would that be okay?

I will mark your next reply as private so that I can get log-in credentials from you—you may want to create a temporary admin user for me to use that you can later delete. And be sure to have a current backup of your site, even though I don't intend to make any changes.

What's the name of the Content Template you have assigned to the post (and what is the post type and title)?

#912220

Nigel
Supporter

Languages: Englisch (English ) Spanisch (Español )

Timezone: Europe/London (GMT+00:00)

Hi Jason

I tried to access but was blocked by WordFence.

I'm in Ireland, if you could greenlight it.

#912402

Got it. It's greenlighted.

#912969

Nigel
Supporter

Languages: Englisch (English ) Spanisch (Español )

Timezone: Europe/London (GMT+00:00)

Hi Jason

I took a look the linked pages but it's not clear how this works so I can't see what might be wrong.

The post 55981 is the Vignette Gallery "The Ladybug" and the post 55982 is a child of this post.

I take it when displaying 55981 you are inserting 55982 but I can't see how. Can you elaborate on how and where exactly you do it? You showed the PHP in your initial post, but where are you adding that code?

(I can't inspect/edit your theme files from the admin area to look. I thought I might take a copy of the site so that I could look at the files locally, but you there was a 500 error on the add new plugins page.)

The view_template attribute is required on the wpv-post-body shortcode, you should specify view_template="None" if no template is being used. (https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-body)

#912995

That php code is inserted into the page template. Since I am using Dynamik as my theme, you can see this in the WP admin. Go to Dynamik -> Custom -> Templates.

If you look at the php code for the one named "single" - you will see the php code for that page template and the code that makes 55982 the child of 55981.

Thanks!

#913232

Hi Nigel,

I tried inserting view_template="None" into the code but it didn't seem to work. I did figure out an easy workaround. I can make a custom field and insert the code in there (in the same post) - which solves the problem. It doesn't fix the fact that the content template behavior seems to have changed at some point - not sure if this would ever be a problem for anyone else, but I can use this workaround.

#913251

I am going to mark this as resolved. I'm having to redo everything I've built which is a pain in the neck, but it's ultimately better to have it all on one post with a custom field than melding two posts together. Thanks for leading me to a good solution!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.