Skip Navigation

[Resolved] Q: How to successfully apply WP-View Template to 17,000+ posts

This support ticket is created 9 years, 8 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.

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
- 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 -
- - - - - - -

Supporter timezone: Europe/Madrid (GMT+01:00)

Tagged: 

This topic contains 8 replies, has 2 voices.

Last updated by johnM-2 9 years, 8 months ago.

Assisted by: Caridad.

Author
Posts
#209909

Hi,

Background
==========

Currently using PODS for site but switching back to WP-Types. Have approximately 17,000 existing posts that I want to apply a WP Views template against to replace the current PODS template. I created a WP-Views template and tried to use the "Apply to All?? to have it cascade the template through all posts but it only seems to apply the template to a few 100 hundred or so. I already have the previous PODS fields under WP-Types control now and these are displaying in the post edit screen as expected. I have another custom post type called Resources which is working fine with both WP-Types and WP-Views.

Issue
=====

Applying template to all 17,000 posts

Question
=========

Is it just one field that needs to be updated in the WP database? By that I mean can I run some SQL via PHPMyAdmin to apply the WP Views template to the post rather than using the “Apply to all" from the WordPress Admin?

Hope this makes sense. Thanks for your help.

#209955

Dear John,

I did some testing with 1700 posts local and it was working fine. Can I have access to your Dashboard to review why it fails there?
You can use the boxes below the comment area, after you agree to the disclaimer.

Thanks
Caridad

#209962

Thanks Caridad,

I have included the log in information to you privately. The site is live however and POD's are still active because it is driving the output for the site still.

Regards...John.

#209978

Dear John,

Im not sure what is wrong. Any operation I try to do with posts ends up with an error. Can you enable WP_DEBUG and follow the instructions for "PHP Debbugging" here?

https://toolset.com/documentation/user-guides/debugging-types-and-views/

Let see what you get in the error_log.txt file.

Regards,
Caridad

#209983

Hi Caridad,

Thank you for helping me I appreciate it. I think if you are trying to activate a view (i.e. assign a template to a post) it will throw an error because PODS is till activated and more critically I have a custom plugin installed that applies the PODS template to every single post automatically--I've been caught out on that myself whilst trying to debug this. So, in order to assign a view to a post it requires deactivating my custom plugin prior to assigning the view template.

However, my problem is not so much getting view templates to display on the front end as much as it is assigning the views template to all 17,000 posts i.e. the "Apply to all" unfortunately does not apply to all posts in my instance. Do you know what field/s are being updated in the database when the View Template is applied?

Thank you once again....John.

#209985

Sorry I should have explained that better. My problem is not with displaying views once they are assigned to post. My problem is assigning the template to all 17,000 posts using the "Apply to all" which is why I was looking for a way to execute this change via SQL directly in PHPMyAdmin thereby bypassing whatever was causing the "Apply to all" problem in the WP admin.

#209990

Dear John,

I understand the problem but you need to be able to do the change from the admin interface.

Internally this is stored as a record in the postmeta table, with the key '_views_template'.

Regards
Caridad

#210004

Thanks once again Caridad, tomorrow I think I will put the site into maintenance mode, switch off PODS and my custom plugin and then try the "Apply to all" from the admin interface.

Best regards...John.

#211223

Ok, so that didn't work. Still faced the same problem. Managed to hack around it with a plugin with an add filter function from an example provided in one of the other forum posts here recently by I think one of your staff. I've added it below in case anyone else comes across this problem.

function force_template_for_all_posts( $template_selected, $id, $kind ) {
    if ( is_single() && get_post_type() != 'not-this-post-type' ) {  // what posts or CPT's you want included or excluded
        $template_selected = xxxxx; // put your template id here
    }
    return $template_selected;
}

add_filter( 'wpv_filter_force_template', 'force_template_for_all_posts', 99, 3 );

In the above instance you do not need to apply a post type to the content template that you are using as an over-ride.

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