Shortcode Usage
To use this shortcode, add the following to your page or post content:
[groups-listing title="Popular Groups" per_page="5" type="popular" order="DESC"]
Shortcode Parameters
| Parameter | Type | Description |
|---|---|---|
title |
string | Title of the groups section. |
type |
string | Sets order based on type: newest, active, popular, alphabetical, random. |
order |
string | Sort order: ASC or DESC. |
orderby |
string | Property to sort by: date_created, last_activity, total_member_count, name, random. |
page |
int | Page offset of results (e.g., 1, 2, etc.). |
per_page |
int | Number of groups displayed per page. |
max |
int/bool | Maximum groups to display. Only effective if less than per_page. |
user_id |
int | Limit groups to those the specified user is a member of. |
group_type |
string | Filter by specific group type. |
group_type__in |
string | Comma-separated list of group types to include. |
group_type__not_in |
string | Comma-separated list of group types to exclude. |
status |
string | Comma-separated list of group statuses to filter (e.g., public, private). |
include |
int/string | Comma-separated list of group IDs to include. |
exclude |
int/string | Comma-separated list of group IDs to exclude. |
parent_id |
int | Limit results to child groups of the specified parent group ID. |
grid |
string | Display format: yes for grid layout, no for list layout. |
loop_layout |
string | Grid layout columns: two, three, four. Only effective if grid=yes. |
container_class |
string | CSS class for the container. Default is groups. |
Filters and Actions
Filters
group_shortcode_attributes- Description: Modify shortcode attributes before they are processed.
- Usage Example:
add_filter( 'group_shortcode_attributes', function( $atts ) { $atts['title'] = 'Featured Groups'; return $atts; });
group_shortcode_bash_query_args- Description: Adjust the query arguments for filtering groups.
- Usage Example:
add_filter( 'group_shortcode_bash_query_args', function( $query_args ) { $query_args['order'] = 'ASC'; return $query_args; });
group_shortcode_template_args- Description: Modify the arguments passed to the group template.
- Usage Example:
add_filter( 'group_shortcode_template_args', function( $args ) { $args['column'] = 'two'; return $args; });
group_shortcode_output- Description: Adjust the final output of the shortcode before it’s returned.
- Usage Example:
add_filter( 'group_shortcode_output', function( $output ) { return '<div class="custom-wrapper">' . $output . '</div>'; });
Actions
before_group_shortcode_render- Description: Triggered before the group content is rendered.
- Usage Example:
add_action( 'before_group_shortcode_render', function( $atts ) { echo '<p>Before Group Listing</p>'; });
group_shortcode_inside_container- Description: Triggered inside the group container for adding custom content.
- Usage Example:
add_action( 'group_shortcode_inside_container', function( $atts, $template_args ) { echo '<div class="custom-content">Additional Content</div>'; }, 10, 2 );
after_group_shortcode_render- Description: Triggered after the group content is rendered.
- Usage Example:
add_action( 'after_group_shortcode_render', function( $args ) { echo '<p>After Group Listing</p>'; });
Example Shortcode Configurations
Example 1: Newest Groups in Grid Layout
[groups-listing title="Newest Groups" type="newest" grid="yes" loop_layout="three"]
- Explanation: Displays newest groups in a 3-column grid layout.
Example 2: Popular Groups with Custom Order
[groups-listing title="Popular Groups" type="popular" order="ASC"]
- Explanation: Shows popular groups sorted in ascending order.
Example 3: Groups for a Specific User with Hidden Container
[groups-listing user_id="123" container_class="hidden-groups"]
- Explanation: Limits groups to those the user with ID 123 is a member of and applies a custom CSS class.
Example 4: Alphabetical Group List Layout
[groups-listing orderby="name" order="ASC" grid="no"]
- Explanation: Displays groups in alphabetical order in a list layout.
Example 5: Filtering Groups by Type
[groups-listing title="Project Groups" group_type="project"]
- Explanation: Filters to show only groups of the type
project.
Example 6: Specific Group IDs with Exclusions
[groups-listing include="101,102,103" exclude="104,105"]
- Explanation: Includes only groups with IDs 101, 102, and 103, while excluding 104 and 105.
Example 7: Custom Container and Display Limit
[groups-listing container_class="custom-group-container" per_page="5" max="10"]
- Explanation: Applies a custom CSS class and limits the display to 10 groups, with 5 per page.
Example 8: Group Status Filtering
[groups-listing title="Private Groups" status="private"]
- Explanation: Shows only private groups with a specified title.
Example 9: Parent-Child Group Filtering
[groups-listing parent_id="200" grid="yes" loop_layout="two"]
- Explanation: Shows child groups of parent group ID 200 in a 2-column grid.
Example 10: Display Random Groups with “Last Activity” Sort
[groups-listing orderby="last_activity" type="random" per_page="3"]
- Explanation: Shows 3 random groups sorted by last activity.
This documentation provides a comprehensive guide to using the Group ShortCode with various parameters and customization options using filters and actions.
