Related Posts Block
The Related Posts block automatically displays WordPress posts that are related to the current Itinerator page based on shared taxonomy terms. It's perfect for showing relevant blog posts, articles, or custom content that relates to a specific region, itinerary, listing, or event.
Overview
The Related Posts block intelligently finds and displays posts that share taxonomy terms with the current page. For example, if you're viewing a region page, it will show posts tagged with the same region taxonomy term. This creates natural content connections and helps visitors discover related information.
Use Cases:
- Show blog posts about a specific region on region pages
- Display articles related to an itinerary on itinerary pages
- Feature news or updates about a business on listing pages
- Create content hubs around specific events or destinations
Block Features & Options
Display Modes
- Card Layout: Posts display in a responsive grid with featured images, titles, excerpts, and read more links
- Content Toggles: Control which elements to show (image, title, excerpt, read more link)
Layout Options
- Number of Posts: Set how many related posts to display (default: 3)
- Sort Order: Choose from date (newest first), title (A-Z), name (A-Z), last modified, or random
- Post Types: Select which WordPress post types to include (e.g., Posts, Pages, Events)
Automatic Filtering (New)
The block provides intuitive checkboxes to automatically filter content based on the current page context:
- Filter by Current Region: Shows posts tagged with the region of the current page. (Available on all pages)
- Filter by Current Itinerary: Shows posts tagged with the current itinerary. (Available on Itinerary pages)
- Filter by Related Itineraries: Shows posts tagged with any of the itineraries related to the current listing. (Available on Listing pages)
- Filter by Current Listing: Shows posts tagged with the current listing. (Available only on Listing pages)
Filter Logic:
- Match ALL filters (AND): Shows posts that match every checked filter (e.g., tagged with Region AND Itinerary).
- Match ANY filter (OR): Shows posts that match at least one checked filter (e.g., tagged with Region OR Itinerary).
Advanced Query
- Custom Query String: Override or extend the automatic matching with custom WordPress query parameters.
- Shortcode Support: Supports dynamic values like
category=[itin-stripped-slug]oritin-regions=[itin-stripped-id].
Display Toggles
- Show Image: Display featured images for each post
- Show Title: Show post titles
- Show Excerpt: Display post excerpts
- Show Read More: Include "Read More" links
Configuration
Enabling Taxonomies on Post Types
By default, Itinerator taxonomies (Regions, Itineraries, Listings) are only enabled for standard WordPress Posts. To use this block with other post types (like Pages or custom types):
- Go to Itinerator > Settings.
- Find the "Enable Taxonomies for Post Types" field.
- Enter a comma-separated list of post type slugs (e.g.,
post, page, event). - Save settings.
Adding the Block
- Add the Block: In the block editor, search for "Related Posts" and add it to your page
- Select Post Types: Choose which content types to search.
- Configure Filters: Check the boxes for "Filter by Current Region", etc.
- Adjust Logic: Choose "Match ALL" or "Match ANY" if using multiple filters.
Shortcode Usage
Basic Shortcode
[tourismo-related-posts]
All Available Options
| Option | Type | Default | Description |
|---|---|---|---|
display_count |
number | 3 | Number of posts to display |
sort_by |
string | "date" | Sort order: "date", "title", "name", "modified", "rand" |
post_types |
string | "post" | Comma-separated list of post type slugs |
filter_by_region |
boolean | true | Filter by current region ID |
filter_by_itinerary |
boolean | false | Filter by current itinerary ID |
filter_by_listing |
boolean | false | Filter by current listing ID |
tax_query_relation |
string | "AND" | "AND" or "OR" logic for multiple filters |
custom_query |
string | "" | Custom WordPress query parameters |
show_image |
boolean | true | Show featured images |
show_title |
boolean | true | Show post titles |
show_excerpt |
boolean | true | Show post excerpts |
show_read_more |
boolean | true | Show "Read More" links |
class_name |
string | "" | Additional CSS classes |
Practical Examples
Show 5 recent posts about the current region:
[tourismo-related-posts display_count="5" sort_by="date" filter_by_region="true"]
Show posts that match EITHER the Region OR the Itinerary:
[tourismo-related-posts filter_by_region="true" filter_by_itinerary="true" tax_query_relation="OR"]
Display pages and posts sorted by title:
[tourismo-related-posts post_types="post,page" sort_by="title"]
Advanced: Show posts from a specific category:
[tourismo-related-posts custom_query="category=news"]
Advanced: Show posts with specific tags:
[tourismo-related-posts custom_query="tag=featured"]
Related Blocks
- Itineraries Block - Display itinerary collections
- Listings Block - Show business and attraction listings
- Events Block - Display event collections
- Regions Block - Show region collections