Skip Navigation

[Resolved] Singe Posts Custom Template Showing on Homepage Archives

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

Last updated by brianC-14 4 years, 10 months ago.

Assisted by: Waqar.

Author
Posts
#1740477
Posts Template Settings.png
Posts Template Settings 2.png

Hello,
I recently switched my site over to the new version of Toolset Types/Blocks, as well as a theme from GeneratePress (which is one of your recommended themes). I do not have this on my production site at the moment, I am first trying to get everything setup and tested locally.

I used Toolset Types to create one new custom template, explicitly for Posts single page (I included screenshots of these settings). I do NOT have a custom template specified for the Post archive at all. This is intentional.

All of my posts use the Read More tag. When I view them in a Category or Tag Archive, they are all properly observing that Read More tag by cutting off the content there. This is behaving exactly as expected. Also on a post single page, my custom fields that I put into my template are showing, which is also behaving exactly as expected.

The issue comes in on the homepage. My understanding is that when you elect to have posts shown on the homepage, this is the same as an archive (which I established earlier this functionality is working as desired on archive pages). However the entire content of each post is shown on the homepage, along with my custom fields. This clearly means that the Post Single Page content template is somehow being applied to the homepage as well, though I'm not even really sure how that would be.

I first started this as a ticket with GeneratePress. When they asked me to start disabling plugins, I started getting the Read More tag on my homepage posts only when disabling Toolset Types Blocks. Is this a setting I'm messing, or something I'm doing wrong somehow? Some kind of misunderstanding on my part as to what WordPress does with posts on the homepage?

Thank you for your help.

#1741551

Hi,

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

This is the expected behavior and you'll experience the same, even with the default Twenty Twenty theme.

When a content template is assigned to single post pages, the theme picks that up to show posts on the homepage, and when it is not present, it will use the fallback template which is the same as the one for the other archive pages, in most themes.

To show a list of posts on the homepage, with a different design/layout than the single post pages, you can create a new WordPress Archive for "Home/Blog", from WP Admin -> Toolset -> WordPress Archives.
( example screenshot: hidden link )

Here is a useful guide on creating WordPress Archives:
https://toolset.com/course-lesson/creating-a-custom-archive-page/

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1741879

Thanks for your reply. While I definitely recognize I could solve the problem this way, let me ask a different question:

Is it possible to take the existing custom template that I have (which we've established is used for both single posts and the homepage, but not archives), and tell it to cut off via the readmore tag on the homepage view, but not on the single view? It sounds like default WordPress themes do that by default, but the difference here is that doesn't involve a Toolset Types custom template to show custom fields.

Thanks.

#1742019

Thanks for writing back.

In this particular case, you can use the "wpv_filter_force_template"
( ref: https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_force_template )

For example:


add_filter( 'wpv_filter_force_template', 'filter_check_for_specific_filter', 99, 3 );
function filter_check_for_specific_filter( $template_selected, $id, $kind ) {
	// check if a specific template is being called on a page other than the single post page
	if (($kind != 'single-post') && ($template_selected == 123)) {
		// if yes, unset that content template
		$template_selected = 0;
	}

	return $template_selected;
}

Note: You'll replace "123" with the actual ID of the content template assigned to single post pages.

The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through active theme's "functions.php" file.

As a result, that content template will be strictly used only on the single post pages and not on any other type of page(s), including the homepage.

#1742549

That took care of it, thanks very much!