[Resuelto] Using an archive layout in an archive-CPT.php loop
This support ticket is created hace 7 años. 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.
Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.
Tell us what you are trying to do?
I'm trying to use an archive layout in an archive-CPT.php loop.
The theme has no archive.php and I am only working on one specific part for a sub-client (alumni side of a non-profit). I can't use layouts because the majority of the site is custom coded.
I have a nice archive layout that is on my dev server, and it works on the live server except I really need to use a different template since index.php is displaying horribly (it's never used, as I said, this is a custom site/nightmare).
Is it possible to use an archive layout inside a archive-CPT.php loop? I don't want to lose the view and hardcoding it is a lot of work and the reason I use views 🙂
Is there any documentation that you are following? no
Is there a similar example that we can see? enlace oculto
What is the link to your site? (dev version, different theme) enlace oculto
We need to be careful of terminology here to avoid confusion.
When you say you want to use an archive layout in a PHP template on a site that can't use Layouts, you don't mean an archive designed in Layouts, right?
You mean you have designed an archive with Views at Toolset > WordPress Archives and you want to use that in a PHP template?
On a site where Views is not installed/active?
Is that the question? Because if so then the short answer is no. You can't create a template in Views and then export it as a stand alone PHP template with no dependency on Views itself. You can insert a View into a PHP template, but Views must be active on the site.
If I have misunderstood could you please elaborate?
No that's not the question. VIews is installed on the other site. I can't use layouts so forget that part.
I have to create an archive-CPT.php file and want to know if I can put the designed Views at Toolset > WordPress Archives into the file.
If you look at the 2 sites you will see the difference. The one on upwithpeople.org is using the index.php file that is custom made (there is no archive.php file in any case).
So basically, I have to create an archive-CPT.php file and wonder if I can insert the view somehow. If not, I lose most of the reason to even use toolset.
I know the site is a mess, the company that designed it has stopped working on it since all their developers left.
I'm sorry if I'm being a bit slow here, but if the other site has Views installed then why not export the Views custom archive to the other site and assign it to the post type?
Although similar, custom archives work differently to Views. You can insert a View into a PHP template using do_shortcode, but there is no equivalent for custom archives.
You can export the archive and re-import to the other site at Toolset > Export / Import > Views
The reason is formatting. If you look at the 2 sites I put up, you will see that the upwithpeople.org site looks terrible. There is no archive.php. If you click to any other pages you will see that bootstrap and the divs are setup.
The view is already at: enlace oculto
Can I put the view into a archive-cpt.php file with the short code? Or does it only work with non-archives? Seems like a big flaw if this doesn't work for custom archives since that is the whole point of using types and views.
I understand this is complicated because terminology overlaps.
Let me clarify a few things about how this works so you can decide what option suits you best.
A Views custom WordPress archive works by intercepting the while ( have_posts() ) : the_post(); part of the PHP template used for the archive (e.g. archive.php if it exists, index.php if not). The rest of the page is generated by the PHP template, itself.
If you design a custom archive on one site and export it to another it's not necessarily going to look the same as the site it came from or the site it is imported into, it depends very much on the markup of template that sets up the content area, with sections and container divs and such like.
The markup on the page you linked to is very different to the markup on the page linked to at the top, enlace oculto. And the most obvious differences are in the structural markup that surround the content area, rather than the content area itself which is what your custom archive will replace.
That other page which is an "Upbeat archive" page is not really an archive. It is a static page with a View inserted.
That might be the best approach for you. Instead of using the actual archive, make a static page to use in place of the archive, and create a View that you insert on that page. Then it will be using the same structural markup from the page template as the other pages. Views and custom archives are not the same but are similar enough that you should be able to copy your Loop Output section from the archive on one site and paste it into a View Loop Output section in your target site and just set the relevant options for what the View displays as required.
I'm not sure why you were looking at enlace oculto That is the page that is being replaced.
The one at enlace oculto is currently not live and is the one which has the archive view.
That is also the same exact view that is on enlace oculto
I understand that the dev.jongriffin.com page will have different headers etc. Hence the question of how to add the view with a shortcut to an archive.php page. There is no archive.php page on either site, so I have to create that, no problem, I can just use the main divs etc from another page. Is there a shortcut to add the view to archive.php?
Okay, I figured out what you meant. The terminology is what threw me off. I have a static page and inserted the loop (which I had to create since you can't use an archive view).