• ok so what exactly is an archive page?
    i just figured its a query showing every item in this current taxonomy or post type.

    but the search results are apparently also considered an archive page…
    can someone explain it? pretend your talking to a moron….
    lol you might not have to pretend…

Viewing 10 replies - 1 through 10 (of 10 total)
  • An archive page is just a list of posts. So the main posts page, tag, category and date-based archives are all archive pages.

    Thread Starter Eric

    (@shamai)

    yeah but the filter pre_get_posts does not work for just any page you create.
    I once had a page where i then querieid for portfolio items and I tried using pre_get_posts and it does not work.
    only on archive pages.

    so I am in need of a better explanation

    I once had a page where i then querieid for portfolio items

    Was this a custom page template? If so, that;s still classed as a static page – not an archive. All archive pages are generated on demand and do not exist as Pages.

    Thread Starter Eric

    (@shamai)

    so archive pages are dynamic pages NOT made by any specials queries i create?
    just the basic loop and the wp core takes care of it?

    so archive pages are dynamic pages NOT made by any specials queries i create?

    Archives – yes. In effect, they’re defined by their template files (tag.php, category.php etc).

    Thread Starter Eric

    (@shamai)

    so index.php is an archive page for a blog?

    Yep. I think the full list is:
    index.php
    archive.php
    category.php
    tag.php
    taxonomy.php

    and all variations of those templates.

    Thread Starter Eric

    (@shamai)

    what about a post type?
    archive-{post_type}.php
    ?

    That would come under “all variations of those templates”. ??

    Moderator keesiemeijer

    (@keesiemeijer)

    yeah but the filter pre_get_posts does not work for just any page you create

    The hook (‘pre_get_posts’) is called after the query variable object is already created. For a “Page” request the query object is set with variables as ‘pagename’, ‘is_page’, ‘is_singular’ and the page object for the page itself. On other (post archives) requests the post objects are as esmi said generated on demand.

    You could change the “Page” object variables with the pre_get_post action (and other action hooks), but this would probably break things down the road.

    That’s why it’s recommended you query with WP_Query in the page template of your (child) theme if you want to alter the main loop for a page (request).

    https://codex.www.ads-software.com/Function_Reference/WP_Query

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘understanding archive pages’ is closed to new replies.