I am trying to:
I have multiple posts under a CPT (businesses). Each business is either Premium, or free - therefore is either '1' or '0'.
The Premium template works fine, but when it comes to the free listings, I have a problem.
I have a conditional layout, where if it's not a premium listing, it displays a different layout.
However, this doesn't seem to be working on some posts, but there's no reason why.
Link to a page where the issue can be seen:
For example,
Premium listing (Works great):
hidden link
Not a premium listing (works great):
hidden link
Not a premium listing (doesn't work):
hidden link
As far as I know, there is no difference in the 2 basic listings (they were imported via WP All Import at the same time)
I expected to see:
I don't understand why the Content Template is not working correctly for all basic listings. It only shows on some, not all. It seems to be reverting to a basic template on some of the listings.
Aargh, for some reason, it's not selecting the appropriate content template on some of them. So it's not selecting the 'Template for Businesses' template, it's reverting to the standard single.php from the template.
I don't know why it's done that on some of them, but it's okay on others?
I have a conditional layout, where if it's not a premium listing, it displays a different layout.
Can you explain in technical terms how this is accomplished? Is there custom code in place using our Views filters? Or perhaps some conditional code written into the template itself? If so, can you share it here for me to review?
Aargh, for some reason, it's not selecting the appropriate content template on some of them.
Are you saying that when you edit these posts in wp-admin, the correct content template is not selected, or are you saying it's selected but not displayed on the front-end of the site?
Sorry for not being totally clear, I only noticed what was happening after I had posted this.
It's using the same content template, but has a conditional which either displays one layout or another.
The problem is that the content template is not selected on some of the posts.
Okay the Content Template associated with each post is stored in the postmeta table under the key _views_template. So I'm not sure if the import process failed to transfer that meta value over into the new site, or if the value was corrupted during the transfer, or if something else is going on. I could examine the original and migrated databases if you want to provide database dump files of each one, or if you're comfortable examining the databases directly you can provide more details for me. I would first check in the original DB the postmeta table for the _views_template value for one of the posts that didn't transfer correctly. If there is a value, check in the migrated DB to see if the same value ported over for the same post in postmeta. If so, check to see if that value corresponds to any Content Template ID. If not, this indicates a corruption of IDs because your Content Template IDs aren't identical across sites.
If you would prefer to let me check, feel free to post the database dump files to Drive or Dropbox and provide a download link here for me. All URLs you share here in forum comments are obscured from other Users for your security.
Hi Christian,
Sorry for the delay, I haven't been in the office.
I'm not exporting from a WP database, I'm just importing from a CSV with some quite basic information.
So, I guess it hasn't registered the content template in the meta on the import for some of them.
Would it help to see the CSV?
Yes, that would be helpful. Please post the CSV file somewhere and provide a download link for me. When you import this CSV content into another site, is that site a fresh WP installation or does it already include content?
It's a new WordPress installation. Prior to import, it had about 6 posts (in this particular post type), post install, it's got over 200,000.
Is there a way of bulk-updating the content template via the DB? I won't need to do it again now that they're in - so it might just be worth running a bulk update if that's possible.
Thanks for your help, Christian. 🙂
I'm pretty sure I've resolved this by running another import on the 206,000 (eurgh), and setting the content template ID as I found I can get to that custom field through WP All Import Pro. So, it's currently running through and updating the blank ones. Not sure why it didn't put them all in initially, but like I say - this is a single time import, so not really a problem.
Thanks again 🙂
Oh okay, well feel free to resolve or reopen here if you need more assistance.