Query Var - Dynamic Shortcodes

Explore the Query Var Dynamic Shortcode for retrieving WordPress query variables.

Updated over a week ago

The query var dynamic shortcode allows you to retrieve different query variables within a page or post.

Syntax

{query_var:name}
  • name: The name of the query variable you want to retrieve.

Examples

  1. Basic Usage: {query_var:author}
    Retrieves the author query variable. Useful for displaying the author of a post.

  2. Page ID Retrieval: {query_var:page_id}
    Fetches the page ID. Ideal for use in templates where the page ID is needed for further processing or conditional content.

  3. Search Term: {query_var:s}
    Grabs the current search term. This is particularly handy for custom search results pages, allowing the display or use of the search term entered by the user.

  4. Post Status: {query_var:post_status}
    Retrieves the status of the post (e.g., 'publish', 'draft'). Useful for conditional displays based on the post's status.

  5. Category Name: {query_var:category_name}
    Gets the name of the current category.

Special Privileges

Access to certain query variables may require elevated privileges. In such cases, the shortcode must be used within a Power Shortcode to ensure proper access and functionality.

Did this answer your question?