Skip Navigation

[Resolved] Archive template not used and featured image shown twice

This thread is resolved. Here is a description of the problem and solution.

Problem:
When using Content Templates for the Archive (single) posts, those aren't applied to those posts.
Also, in single posts, I see the featured image twice.
Once, I inserted in the Content Template, but it's unclear where the second one comes from.

Solution:
The Content Templates can only replace the_content function, or any other valid function that outputs the content (body) of a post.
You can see here how to proceed if your Theme doesn't use the native WordPress the_content() function:
https://toolset.com/documentation/user-guides/templates/theme-support-for-content-templates/

Now the Featured image is usually output already by the Theme, and if the theme offers no option to turn that off, the only ways of having the Featured Image displayed only once is either remove it from The Content Template (and let the theme display it) or arrange the theme's code in a Child Theme so to not output it.

Or, using any theme that offers options for it would as well solve the issue.

This support ticket is created 5 years 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 9 replies, has 2 voices.

Last updated by Beda 5 years ago.

Assisted by: Beda.

Author
Posts
#1436307

Hello,
I am trying to use an archive template for displaying a CPT taxonomy (category).
The CPT is Annonces
The archive template for that CPT is Archive Annonces.

It does not work, what I am getting instead in the regular taxonomy view for the "post" post type.

I had a similar issue about the content template for single view and it has been fixed in that ticket:
https://toolset.com/forums/topic/content-template-not-used/

The tip provided in that ticket to help solving this kind of issue is too technical for me. I have tried but I still do not get it.

Thanks for your help

#1437561

The ticket you linked suggests adding the custom function that the Theme you use uses to display post contents to Toolset's Supported functions.
This is a step that must be done in case the Theme does not use the WordPress default the_content() function to display posts bodies.

Hence, as per that ticket, the "Newspaper" theme uses custom functions to display the single post content (post body) instead of the standard WordPress function the_content()

To solve this you should go to your WordPress Dashboard and then to the Toolset Menu, from which you can navigate to the Settings Submenu, and there choose the tab Front-end Content to find the section "Theme support for Content Templates".

There you'll see an input field, where you'd have to add the Theme's function it uses to display the post body.
That seems to be "td_module_single_base::show_content", hence you can add exactly that to the input and save (enter "td_module_single_base::show_content" without the apostrophes)

This will resolve issues where a Content Template is not shown, even if applied to posts.

With archives, in Toolset, you would create an archive in Toolset > WordPress Archives.
If those archives created and assigned to content there do not apply in the front end, you can try switching the theme for example to Theme TwentyNineteen. If then it works, it'd mean there is a compatibility issue with that Theme - most likely in this case they use another function than the WordPress native Loop.

Now as I recall I debugged this already once in past and the Theme in question here (Newspaper) uses another custom (variable, this time) method to output the content in archives.
As well there will be issues with the sidebar of the Theme since the HTML is generated depending on some Theme settings.
You can see this issue and solution here https://toolset.com/forums/topic/side-bar-not-working-well-when-enable-it-to-custom-archive/#post-522460

It however involves custom code editing, at least a Child Theme would have to be created and edited accordingly.
If you are not comfortable doing this, I would suggest using a Theme that does not use Custom Functions (or if so, then only explicit content rendering functions so you can register them with Toolset)

Please let me know if I can help further with this.

#1437683

Hi Beda,

Thanks for investigating. I understand what you are saying and I also understand that I am not able to create and edit accordingly a child theme by myself.

The fastest workaround consists of using the standard taxonomy template (actually the newspaper theme allows to select some templates specifically for CPT taxonomies even if it does not work either right now).

It turns out the standard taxonomy template uses the post featured image.

That leads me to this question: how can I get the user to submit this featured image through a form? I have already created a form with a "photo" field but this field has not been set as the featured image. How to do that?

Thanks

#1437811

In Forms, Featured Images can be added if the Post Type the form applies to also support featured images.

Once you autogenerated the form or as well manually from the right-hand sidebar with all "blocks" you can use in a Form, you can save the form and insert it to a page to create posts with a featured image.
You'd not need any special field for this.

You can simply either create a new form for posts and use it, or in an old form in the edit area of the form just insert the Featured image from the right-handed section where you can find all the available "blocks" to use in a form

#1438071
form3.jpg
form2.jpg
form1.jpg

Hi Beda,

Thanks for the answer. But I don't get it.

Concerning " Featured Images can be added if the Post Type the form applies to also support featured images":

-> how to make sure the Post Type supports featured images? I am setting up a simple directory with a CPT named "annonces" (meaning ads in French). I have a group of custom fields and I can't see any way to deal with "featured images".

Concerning "in an old form in the edit area of the form just insert the Featured image from the right-handed section where you can find all the available "blocks" to use in a form":

-> I have setup a content form (create) and then inserted it in a dedicated page whose only purpose is to host that form. I can't see any "featured image" block when looking at the "blocks" on the right hand side of the page used for editing the form (see screenshots)

EDIT: I have just thought of something. Actually there is a "block" named "ajouter un media" (that could be translated by "add a media"). Is this the block you are referring to? (see screenshot form3.jpg)

Thanks for your help

#1439255

Let me answer the additional questions below:

1. how to make sure the Post Type supports featured images?

In WordPress, natively only the post type "posts" will have Featured Images.
You can, however, using Toolset Types add Featured Images to Custom Posts as well, when you edit a Custom Post in the WordPress Dashboard Menu "Toolset > Post Types > Edit > Sections to display when editing this Post Type. There, check the "Featured Image" checkbox.

This will enable the Featured Images feature as well on your Custom Posts.
This is not something you'd do in "Custom Fields", because Custom Fields are additional fields that are not natively included in WordPress (Like a Featured Image is).

2. Above is also the reason you do not see the "Featured Image" block I mentioned in the Forms edit screen.
Since that Post Type currently does not support it, it won't appear in the corresponding Forms.

3. The "Add media" is different, there are a few ways to add media generally to a Form.
You can use the native Post Body Editor that a Form uses to add media, or you can use Types Custom Fields of media type, or you can even use generic fields in the Form to add media and manipulate it later with custom code for example (this is again a more advanced and very particular usage case of the Forms)

You want the Featured Image, hence, you'd need to activate Featured Image support for the Post Type "annonces" in Toolset > Post Types > Edit > Sections to display when editing this Post Type.

Then, in the Form that creates new annonces you should be able to add the Featured Image "block".

#1442227

Hi Beda,

AWESOME! That was the info I was missing and now it works as you say.

That leads me to a final question as a result of implementing this:

I have just found out that the content template for the single view is NOT the only one piece of code that takes control of the post body content layout. What I mean by that is that the featured image gets inserted at the very top of the post even if I did not set it up that way in the content template. Actually that's the way standard posts are managed by the theme.

Is there a way to prevent that from happening? That's not a big deal, I can live with that, but would like to know anyway.
(will it be again a matter of implementing custom coding + child theme? )

Thanks

#1443957

The Content Template applies only to the the_content() part
This function is explained more in-depth here https://developer.wordpress.org/reference/functions/the_content/ but basically, that is the Post Body.

So, if a Theme outputs the_content() somewhere then that's what Toolset Content Templates replace. The title (the_title()) and Featured Image (the_post_thumbnail()) are not part of the_content(), hence, they display even if you apply a Content Template to the post.

Some Themes offer options to turn the display of Title, Featured Image or even author data on and off.
Other themes even integrate that with Toolset Content Templates: https://toolset.com/documentation/recommended-themes/

You could approach this in different ways:
- use a theme that supports Content Templates as under the link above.
- use an option your current theme eventually provides to turn the Featured Image off, and then insert it within the Content Template
- modify your theme in a child theme so to add such an option or remove the Featured Image
- find a theme that offers such controls

The takeaway is, Content Templates replace the_content() and that is where the Theme will output the post body.

If you are interested in editing your website in a totally "clean slate", where you design edge to edge of what you see on the screen, using Toolset, then I can suggest to try out a very specific form of Theme. You can start with this: hidden link

It's a theme that is fully commented in the code and explains step by step what's done and how and why.
It also integrates with Toolset Layouts or Content Templates to allow full template editing.
But this is not how "generally" themes work, WordPress wants a theme to output all kind of stuff, assuming the theme should be responsible for the "design". That is why a WordPress theme will, of course, add the title, author info, etc along with the content.

A custom theme like the one linked above instead is designed to be styled thru a plugin (Toolset) which allows full template editing.
This is, just to be clear, absolutely unnecessary if you want to style the_content (post body) only, which is the default case for Toolset and most other "page builders".

Please let me know if you need any more details!

#1445163

Hi Beda, thanks a lot again for your feedback that totally helps clear the confusion away.

I understand what you say and for the time being I will cope with this featured image as is. But that makes me consider switching to a theme more compliant with toolset. I have checked out the toolset modules and all these grids and sliders could make the trick instead of the theme I am currently using. I find the "clean slate" idea interesting.

Thanks again for this support thread, it's been very helpful.

#1445827

Great, please let us know if we can help with other questions.