Query Dynamic Content

In this article we're going to explain how to use Query Dynamic Content.

  1. Current Page Number
  2. Current Page Number (Zero Index)
  3. Default Posts Per Page
  4. Total Pages
  5. Total Posts Found
  6. Search Query
  7. Query Var

This is the basis for how users search Posts. Query Dynamic Content offers numerous data points that allow you to interact with what the user is doing or searching for on the site.

Query Dynamic Content

Current Page Number

When an archive is paginating, it stores this as page numbers. When they are page 1 it will output 1 and subsequent pages will be associated to their number.

Current Page Number (Zero Index)

This is similar to Current Page Number, but is zero index based. Meaning page 1 will be page 0. This can be useful for doing math with the page number.

Default Posts Per Page

This will output the WordPress reading setting number of posts per page. It can be changed in Settings > Reading in the WordPress admin area.

Total Pages

This will display the total number of pages included in an archive.

Total Posts Found

This will display the total number of posts included in an archive.

Search Query

This will display the current search query from a user. It is escaped by default as to not cause any hacking on your page.

Query Var

This encompasses any search currently happening in a page. This can range from terms to the meta query data. Internally, this uses the get_query_var function.

See something inaccurate? Let us know