You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在WordPress父页面Sports的子页面Events中展示The Events Calendar?

Solutions to Display The Events Calendar on a Subpage

Got it, let's tackle this issue with The Events Calendar on your Sports > Events subpage. The plugin's default setting only lets you specify a parent page slug, but we have a few reliable workarounds to get the calendar showing exactly where you want it:

1. Use the Built-in Shortcode (Quickest Fix)

The Events Calendar includes a simple shortcode you can drop directly into your subpage content—no coding required:

  • Edit your Events subpage in WordPress.
  • In the page editor, add the shortcode [tribe_events] wherever you want the calendar to appear.
  • If you want to filter events to only show sports-related ones, add parameters like [tribe_events category="sports"] (replace "sports" with your actual event category slug).

This method is perfect if you need a fast, no-fuss solution that integrates seamlessly with your page's existing content.

2. Create a Custom Page Template (More Design Control)

If you want to match the calendar's layout to your subpage's theme or add custom elements around it, a custom template is the way to go:

  • Copy your theme's page.php file (access it via FTP or WordPress's built-in file editor).
  • Rename the copied file to page-events.php (since your subpage slug is "events").
  • Add this comment at the very top of the new file to let WordPress recognize it as a custom template:
    <?php
    /**
     * Template Name: Sports Events Calendar
     */
    ?>
    
  • Locate the main content area in the template (usually where the_content() is called) and replace or add the calendar rendering function:
    <?php tribe_events(); ?>
    
  • Save the file and upload it back to your theme's folder (use a child theme if you haven't already—this prevents changes from being lost when your theme updates).
  • Return to your Events subpage editor, under "Page Attributes" select the "Sports Events Calendar" template, then update the page.

3. Use a Filter Hook to Trick the Plugin (Advanced)

If you want the plugin to treat your subpage as its official event page (so all plugin styles, widgets, and functionality load properly), use this filter hook:

  • Open your theme's functions.php file (stick to a child theme to avoid breaking things during updates).
  • Add this code snippet:
    add_filter( 'tribe_events_is_event_page', 'custom_tribe_events_subpage_check' );
    function custom_tribe_events_subpage_check( $is_event_page ) {
        // Get the current page object
        $current_page = get_post();
        
        // Verify we're on the Events subpage of Sports
        if ( $current_page && 'page' === $current_page->post_type ) {
            $parent_page = get_post( $current_page->post_parent );
            if ( $parent_page && 'sports' === $parent_page->post_name && 'events' === $current_page->post_name ) {
                return true;
            }
        }
        
        // Return the original value if we're not on the target subpage
        return $is_event_page;
    }
    
  • Save the changes. Now the plugin will recognize your Sports > Events subpage as its official event page, loading all associated features automatically.

If you run into any snags—like the shortcode not rendering, or the template not matching your theme's style—feel free to ask for more specific tweaks!

内容的提问来源于stack exchange,提问作者Saroj Shrestha

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 08:40:57