Navigation überspringen

[Gelöst] When to use a view vs an archive?

This support ticket is created vor 3 Jahren, 5 Monaten. 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/Hong_Kong (GMT+08:00)

Dieses Thema enthält 6 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von NickC8880 vor 3 Jahren, 5 Monaten.

Assistiert von: Luo Yang.

Author
Artikel
#2124897

Tell us what you are trying to do?
I would like to create a directory of for a custom post type that can be filtered, searched, sorted etc... It is not clear to me when/why I would use an archive for this as opposed to creating a view within another page. Do they offer any different functionalities? Are there tradeoffs with one or the other?

Is there any documentation that you are following?
There's plenty of documentation articles that seem to describe how to do the same things in one or the other, but I can't find anything that clearly describes the conceptual differences. Here is one example:
https://toolset.com/2016/12/filter-custom-post-types-taxonomy-custom-fields/

#2124995

Hello,

In the normal single post/page, you can display the normal post view.
But in the WordPress Archive page(Post type archive page , taxonomy archive page, WordPress search result page ...), it is recommended to use Toolset WordPress Archive, see our document:
https://toolset.com/glossary/archive/
https://toolset.com/course-lesson/creating-a-custom-archive-page/

#2125439

Thank you, though after reviewing those lessons it still isn't quite clear to me. I suppose my confusion is due to the fact that it seems like you can create all the same functionality of the Archive pages in those videos with a Single Page and Toolset View. I suspect that this isn't quite true, or Toolset Archive pages wouldn't exist at all. So, what is the difference? Here's some questions that I hope will help explain my confusion. There's no need to answer each one since they are somewhat overlapping/redundant - I'm just looking for a conceptual understanding of when to use an Archive vs a Single Page + View

  • Why shouldn't I ignore the Archive pages and just build an "Archive" with a Single Page and View?
  • Does an Archive page have a particular focus/strength for displaying taxonomies? If so, what in particular?
  • Does a View offer more flexibility with regards to the scope of posts that can be included (can include multiple types, filter them better, etc...) or ability to work with other features (say, having a map driven by the posts displayed in the view loop?)
  • Is an Archive Page is just a specialized View for displaying ALL posts of a certain type or taxonomy while a View is meant to be used in a more "custom" fashion - with a narrower or broader scope of displayed posts - and embedded within a larger page with other features?
  • Surely this isn't a complicated topic and I'm just missing some small conceptual detail to make sense of it all. I hope you can help clear it up for me!

    #2125953

    WordPress Archive pages are for displaying post lists, you can use Toolset WordPress Archive to customize it, see the document I mentioned above:
    https://toolset.com/course-lesson/creating-a-custom-archive-page/

    It is not recommended to use normal post view for it, that will conduct unexpected results.

    WordPress single posts/pages are for displaying one single post content, you can use Toolset Content template to customize it:
    https://toolset.com/course-lesson/creating-templates-to-display-custom-posts/

    Archive pages and single posts/pages are complete different, they use different theme files, and different WordPress query, see WP documents:
    https://developer.wordpress.org/themes/basics/template-hierarchy
    You can also edit your theme files to find the difference.

    #2126013

    I apologize, I think something is not being communicated well here...

    I know what single posts/pages are for. I'm asking about how using a Toolset View WITHIN a single post/page to display a list/loop of posts compares to using an archive to display a list of posts.

    My goal is to display a list of posts for a specific custom post type and I am not sure whether I should be doing this with an archive for that post type or with a view that selects for that post type. As far as I can tell (and tried to describe/ask in my previous posts), views and archives seem to offer the same functionality. But surely this is not the case, which you confirmed when you said "It is not recommended to use normal post view for it, that will conduct unexpected results."

    Are you able to elaborate on what the unexpected results are so that I can have a better understanding of this? Similarly, if it isn't too much trouble, could you please try to answer my questions from the previous reply?

    Thank you very much!

    #2126311

    OK, there are lots of questions in this thread, I am trying to answer them one by one:

    Q1) Why shouldn't I ignore the Archive pages and just build an "Archive" with a Single Page and View?
    Again, in the single page, please try normal post view, in the WordPress Archive page, please try Toolset WordPress Archive, please check the answer above:
    https://toolset.com/forums/topic/when-to-use-a-view-vs-an-archive/#post-2125953

    Q2) Does an Archive page have a particular focus/strength for displaying taxonomies? If so, what in particular?
    WP Archive page is for displaying post lists, that is built-in feature of WordPress, there isn't any particular focus/strength for displaying taxonomies

    Q3) Does a View offer more flexibility with regards to the scope of posts that can be included (can include multiple types, filter them better, etc...) or ability to work with other features (say, having a map driven by the posts displayed in the view loop?)

    You can add filters into Views query, see our documents:
    https://toolset.com/documentation/user-guides/views/filtering-views-for-a-specific-text-string-search/
    https://toolset.com/documentation/user-guides/views/date-filters/
    https://toolset.com/documentation/user-guides/views/filtering-views-by-custom-fields/
    https://toolset.com/documentation/user-guides/views/filtering-views-by-taxonomy/
    You can also add custom search form into Views:
    https://toolset.com/course-lesson/creating-a-custom-search/

    Q4) Is an Archive Page is just a specialized View for displaying ALL posts of a certain type or taxonomy while a View is meant to be used in a more "custom" fashion - with a narrower or broader scope of displayed posts - and embedded within a larger page with other features?
    There are lots of WordPress Archive page:
    - Post type archive page
    - Taxonomy archive page
    - Search result page
    ...
    Each archive page is for different usage, you can also add custom search form into the Toolset WordPress Archive, but it will outputs belongs to current archive page, it won't output results of other archive page.
    For example:
    In the archive page of post type "cpt1", it won't output other post type posts.

    Q5) which you confirmed when you said "It is not recommended to use normal post view for it, that will conduct unexpected results."
    For example, some AJAX feature of normal post views won't work as expected in WordPress archive page.

    Hope it is clear by reading above documents.

    #2128039

    Thank you for the more detailed explanation. This was never an issue about how to literally use Archives and Views - the GUIs are quite clear already and the documentation and videos help walk you through it. It was more about which features/functionalities are different in each one - the documentation doesn't really say anything about that.

    The information that you have now provided about filtering in views and only displaying one post type in Archives is the sort of info that I was looking for all along. To the extent that I still have a limited conceptual understanding of WP Archives, I can read about that elsewhere, such as in the WP Codex article you provided.

    This all strikes me as similar to the functional and conceptual differences between using Categories vs Tags. I wouldn't ask about that here because it is a WP issue that is written about in considerable detail elsewhere. But Archives vs Views does concern Toolset, which is why I was inquiring here.

    I still suspect that there are other functional differences that haven't been mentioned here, and that the conceptual differences could be described more clearly. So, I will separately submit some feedback about creating a documentation article that describes this more clearly and thoroughly. This documentation for Custom Fields vs Taxonomies (https://toolset.com/lesson-placement/lesson-placements-1647611-1843427/),was very helpful to me when I was starting to use Toolset and could serve as an example for this proposed lesson. I hope that the information and resources you've provided here will be a helpful starting point for such an article/video, or at least serve to somewhat clarify the issue for other new users.