Skip Navigation

[Resuelto] Create a Glossary page

This support ticket is created hace 5 años, 2 meses. 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.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Etiquetado: ,

Este tema contiene 18 respuestas, tiene 3 mensajes.

Última actualización por Nigel hace 5 años, 2 meses.

Asistido por: Nigel.

Autor
Mensajes
#1330997

Tell us what you are trying to do? I'm trying to reproduce WPBeginner's Glossary (enlace oculto).

Is there any documentation that you are following? Your own!

Is there a similar example that we can see? Yes, see link above. I'd also like to add an A-Z shortlink menu above the terms, like we can see on Slack here: enlace oculto

What is the link to your site? enlace oculto

---

I could probably achieve what I want coding everything by hand but I'm curious to try and set this up entirely with the tools provided by Toolset. If I understand correctly, I should be able to achieve what I want without writing a line of code, correct?

Currently, I have a CPT "Glossary Terms" that uses the Taxonomy "Index".

This CPT uses the archive "archive-glossary.php" which I have uploaded via FTP. The template is "single-glossary.php", which was also uploaded manually via FTP.

Would appreciate if you could steer me in the right direction to create a template for the single page and archive page using Toolset and achieve the desired layout. My attempts so far have been unsuccessful.

Thank you!

PS: I'd like to get rid of pagination.

#1331073

Hello,

Yes, you are right, it is possible with a custom taxonomy "Index", you can try these:
1) Create a WordPress page, display below nested view:
2) Setup a nested view:
a) Parent taxonomy view:
- Query terms of taxonomy "Index"
- In View's loop, display below child post view:
b) Child post view
- Query posts of CPT "Glossary Terms"
- Filter by:
Select posts with taxonomy:
"Index" set by the parent Taxonomy View
- In View's loop, display "Glossary Terms" information.

See our document:
Views Inside Views – Display Nested Multidimensional Lists
https://toolset.com/documentation/user-guides/using-a-child-view-in-a-taxonomy-view-layout/

#1331869

Hey Luo,

Thank you for the information.

I'm having a hard time to create the Archive page following your instruction.

When I go to "Toolset > Dashboard" I can see that "Glossary Terms" has a template associated in the "Archive" column, this template name is "Glossary Terms Archive" and I can find it when I go into "Toolset > WordPress Archive".

Since I would like to use a WP Archive template (not a page), I'm guessing the process is as you described but using a WP Archive. So when I edit the WordPress Archive "Glossary Terms Archive", I select in "Loops Selection" the checkbox "Glossary Terms" under "Custom Post Archives".

So far so good, if I understand well this tells Toolset to use the template we're configuring to display the archive for CPT "Glossary Terms".

I decide to order by "Post title", because I want the results to be sorted alphabetically.

I don't set any filters as I want all results to be pulled.

I don't set any pagination either.

Now on to the "Loop Editor".

In the Loop Wizard, I choose "Unformatted" because we'll be pulling a child-view which will take care of formatting. All I want is a plain-text list of all "Index" terms, with a sub-list of Post-links for each "Glossary terms" for the current Index.

Then in the "Loop item" I select the Parent Taxonomy view I created using the Child post view.

So far, just speaking in terms of configuring the archive page, does it sound like I did everything correctly?

---

Let's now dive into the configuration of the Glossary Terms Taxonomy View (TV) and te Glossary Terms Child-Post View (CPV).

In "Toolset > Views" I have 2 these views, TV is configured as such:

- Content Selection => Taxonomy => Index
- Unchecked "Don't show empty terms" because I want to see all Index terms displayed from A-Z.
- Include terms that have non-empty descendants
- Include children in the post count
- Order by Term name - Ascending
- No limit/offset
- No filters
- Loop unformatted, pulling...
-- Taxonomy title
-- "Glossary Index (Child Post View)"

The CPV view is configured as such:
- Content Selection => Post types => Glossary Terms
- Unchecked "Don't include current page in query result"
- Order by Post title - Ascending
- No limit/offset
- Filtered => Select posts with taxonomy: "Index" set by the parent Taxonomy View
- Loop unrdered list, pulling...
-- Post title with a link

---

Result isn't too bad and I can probably arrange a few things playing around with the code but there are a few issues...

Issue #1 : Our theme uses isotope and on the default archive page this makes the posts show up gradually in a nice masonry style. It looks like Toolset uses the default template so the content is wrapped inside the "x-iso-container" ID. Can we remove that?

Issue #2 : It looks like the loop is executing for every posts rather than just once... How can I avoid that?

Thank you!

#1331873

After thinking this over it looks like the way I configured the "Glossary Terms Archive (Taxonomy View)" is exactly how I'd like the Archive to be displayed.

However, the WP Archive editor forces me to use the wpv-loop so I can't just output the view "[wpv-view name="glossary-terms-taxonomy-view"]".

Is there a way to achieve what I want? The reason I do not want to use a Page is that we want to use the /glossary/ permalink which is the default reserved slug for the CPT "Glossary Terms"

#1331887

Another question/issue...

Trying to style the single page template for each term, it doesn't seem like I have full control over the HTML output.

URL: enlace oculto

Currently this is using the default template for our blog post, which is the default template for "Standard Post Format".

How can I gain control over the full HTML output to change where/how the page title is displayed, remove the "Published 2 months ago" and post date?

This is probably related to the Issue #1 I described previously as gaining full control over the HTML output would allow me to remove the isotope container on the archive template.

Thanks!

#1331895

Apologies for the multiple messages, just keeping you up-to-date with my latest tests.

I was able to make the WP Archive Template for "Glossary Terms" execute only once (Issue #2) by adding a Query Filter configured to "Include only posts with the following IDs: 21755".

Basically, I'm just pulling this glossary term and then in the loop it's configured to display the "Glossary Terms Taxonomy View" so it pulls all Index. It works but seems quite finicky, would there be a cleaner way?

Issue #1 still remains, I'd like to remove the "x-iso-container" wrapper around the content and I'd like to add the classes "max" and "width" to the ".x-main > .x-container" wrapper.

Issue #3 - I'm still unsure how to edit the template for the single page, waiting for your feedback.

All best,
B

#1331957

Issue #1) I assume we are talking about this page:
enlace oculto

I suggest you try these:
Copy your theme file archive.php as file "archive-glossary", edit the new file "archive-glossary", remove those "x-iso-container" wrapper as you want:
https://developer.wordpress.org/themes/basics/template-hierarchy/#custom-post-types
archive-{post_type}.php – If the post type is product, WordPress will look for archive-product.php.

Issue #3) I suggest you follow our document to setup a content template to customize single "Glossary Terms" post
https://toolset.com/documentation/user-guides/view-templates/
If you need more assistance for it, create a new ticket for it, according to our support policy, we prefer one ticket one issue. thanks

#1332965

Issue #1 Solved – I was under the impression we should use either the Loop Editor OR a custom template, didn't realize we could use both. Wonderful.

Issue #2 Needs attention – I found a "dirty" fix but to force the archive loop to pull one post and have the Taxonomy/Child-post views taking care of the rest doesn't seem like the proper way to do that. Is there a cleaner solution?

Issue #3 Solved – I understand the one-ticket-one-issue policy but since this is related to creating the glossary page, which is what this ticket is about, and the ticket contains information helpful to answer this question, I figured it made sense to ask here. Anyway I solved this, thanks.

Waiting for your feedback regarding issue #2!

#1333061

issue #2) It looks like the loop is executing for every posts rather than just once... How can I avoid that?

Yes, it is expected result, since it is nested view, so in each "Index" term, it will run the child post view once.

Views supports cache by default, so it won't load data from database everytime you open that URL, see our document:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-view
attributes: cached (opt):
off
Turns off the caching system for the View.

#1333995

Hello Luo,

Thank you for the follow-up.

I understand that the nested view will run more than once, I'm referring however to the query executed when accessing the archive page: enlace oculto

The default query will pull all posts that belong to the "Glossary" CPT.

Let's say there are 10 results...

The archive page will display 10x the view "glossary-terms-taxonomy-view", which is our nested view.

Executing "glossary-terms-taxonomy-view" once would be enough to iterate through each Index term and return all child posts.

I have "hacked" the archive query by telling it to only return the first post that belong to the "Glossary" CPT but I was wondering if there was a more clever way to do it instead of hacking the query.

Thanks!

#1334705

For the new question:

I have "hacked" the archive query by telling it to only return the first post that belong to the "Glossary" CPT but I was wondering if there was a more clever way to do it instead of hacking the query.

How do you "hacked" the archive query? please provide detail steps to duplicate the same problem, thanks

#1339053

Hey Luo,

What I mean by "hacked" the archive query is that I made it behave how I wanted using a feature that was not meant to be used how I use it.

As you said, the expected behavior for an archive page is to loop through each post.

However, what we've configured here is a Nested View that that pulls all terms of the Index Taxonomy and then displays a child-view of the Glossary Terms for each Index Term.

Executing the nested view once will then display all the results that exist.

So...

When we configure an archive with this nested view, and there are 10 "Glossary Terms", we will have 10 times the nested view that display all results, effectively repeating 10 times the exact same output.

The way to prevent this is to tell the archive to only retrieve the first post using a Query Filter, but it seems like I've "hacked" my way into getting the archive to behave how I want. Is that really how it should be done?

Hope my explanation makes sense.

Thanks!

#1339311

I assume you are going to display the nested view into the archive page.

I don't think you need to do those hack, you can try these:
1) Create a Views WordPress archive for post type "glossary":
https://toolset.com/documentation/getting-started-with-toolset/customize-post-archives/designing-an-archive-without-any-page-builder/

2) in above WordPress archive, section "Loop Editor", display the parent view's shortcode only once.

#1343435

Hello Luo,

The shortcode to display the Taxonomy View is only added once:

[wpv-layout-start]
	<h1 style="margin:2em 0 0.5em;font-size:3em;color:#333;">Title</h1>
	<p style="text-align:justify;">Description</p>
	[wpv-items-found]
	<div class="glossary-quicklinks"><span class="wysiwyg-font-size-small"><a href="#0-9">0-9</a> | <span class="wysiwyg-font-size-small"><a href="#A">A</a> | <a href="#B">B</a> | <a href="#C">C</a> | <a href="#D">D</a> | <a href="#E">E</a> | <a href="#F">F</a> | <a href="#G">G</a> | <a href="#H">H</a> | <a href="#I">I</a> | <a style="background-color: #ffffff;" href="#J">J</a> | <a style="background-color: #ffffff;" href="#K">K</a> | <a style="background-color: #ffffff;" href="#L">L</a> | <a href="#M">M</a> | <a href="#N">N</a> | <a style="background-color: #ffffff;" href="#O">O</a> | <a href="#P">P</a> | <a href="#Q">Q</a> | <a href="#R">R</a> | <a href="#S">S</a> | <a href="#T">T</a> | <a style="background-color: #ffffff;" href="#U">U</a> | <a href="#V">V</a> | <a href="#W">W</a> | <a style="background-color: #ffffff;" href="#X">X</a> | <a style="background-color: #ffffff;" href="#Y">Y</a> | <a href="#Z">Z</a></span></div>
	<!-- wpv-loop-start -->
	<wpv-loop>
    	<div id="glossary">
			[wpv-post-body view_template="loop-item-in-glossary-terms-archive"]
    	</div>
	</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

And here's the loop item:

[wpv-view name="glossary-terms-taxonomy-view"]

Am I missing something?

Thanks again for your help.

#1343813

Nigel
Supporter

Idiomas: Inglés (English ) Español (Español )

Zona horaria: Europe/London (GMT+00:00)

Hi there

Luo is off for the rest of the week, so let me jump in.

I haven't read all the details of the thread, but regarding the last advice from Luo to display the parent view's shortcode only once, I take it he means to insert the View within the Loop Editor but not inside the loop.

Here is an example of the minimal version of a View Loop Editor:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
		<wpv-loop>
          <h3>[wpv-post-link]</h3>
		</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

Note that I didn't use the Loop Wizard, and don't link to a content template where I gather the fields to be output, I'm just directly output the post title as a link in an H3 heading.

The wpv-items-found section displays whenever the View has results to display (instead of the wpv-no-items-found section).

Within that section are the wpv-loop tags. Only what appears directly within these tags is output for each result, i.e. for each iteration of the loop.

You can insert content after the wpv-items-found shortcode but before the opening wpv-loop tag so that it is only displayed if there are results to display but is only shown once.

Similarly you could place something before the wpv-items-found shortcode (but after the wpv-layout-start shortcode) so that it displayed one-time only but regardless of whether there were any results to display or not.

So I think the intention is for you to insert your View somewhere there, but outside of the wpv-loop tags so that it is inserted only once, and not once for every result.