作为主日历页的子页的单个活动

时间:2012-09-12 作者:joshmax

有人有时间经验吗。ly的活动日历?我联系过Time.ly help 他们告诉我这类事情必须是定制的。Soo,我来到值得信赖的WPSE!

你知道有什么方法可以将单个事件显示为主日历页下方的子帖子/页面吗?

例如,当前的permalink结构是:

主日历:domain.com/calendardomain.com/ai1ec_event/single-event-title我想做的是让permalink结构为:

主日历:domain.com/calendar

单个事件:domain.com/calendar/single-event-title

甚至。。。

单个事件:domain.com/calendar/ai1ec_event/single-event-title

这两种方法中的任何一种single event permalinks对我没问题,我只想把它放在Calendar 页面本身。

但我不完全确定从哪里开始。我想我会为任何能给我一个起点的人把它放在那里。

还有,如果有300多名代表的人不介意创建这两个新标签并将其添加到这篇文章中,那就太好了。

  • all-in-one-event-calendar
  • timely
1 个回复
SO网友:Milo

首先,我要说我没有插件的经验或知识,这个答案完全基于对注册插件中使用的帖子类型的代码的30秒扫描,因此您可能会发现这个解决方案的问题,而我快速点击测试事件并没有发现这些问题。话虽如此。。。

其基本要点是取消设置插件注册的post类型,然后使用相同的设置重新注册它,但修改后的重写slug除外。要了解其工作原理,您应该熟悉register_post_type 如果您还没有完成,请执行函数。

为插件注册post类型的代码位于文件中app/helper/class-ai1ec-app-helper.php.

下面的代码在2011主题的函数中进行了测试。php文件。您可以在自己的插件中执行此操作,但必须确保它在事件日历插件的init之后运行。

请务必阅读代码中的所有注释,以了解更改的内容,重要的细节是rewrite 的参数register_post_type 这为我们提供了所需的URL:\'rewrite\' => array( \'slug\' => \'calendar/event\', \'with_front\' => false )

add_action( \'init\', \'wpa64981_event_calendar_init\' );

function wpa64981_event_calendar_init() {

    // make sure the plugin is active and has set itself up
    if( defined( \'AI1EC_POST_TYPE\' ) ) :

        // globalize the post types array and some plugin settings we\'ll need
        global $wp_post_types, $ai1ec_settings, $ai1ec_app_helper;

        // unset the original post type created by the plugin
        unset( $wp_post_types[ AI1EC_POST_TYPE ] );

        // the labels array was copied wholesale from the plugin
        // EXCEPT \'all_items\' value, which originally reference $this
        $labels = array(
            \'name\' => _x( \'Events\', \'Custom post type name\', AI1EC_PLUGIN_NAME ),
            \'singular_name\' => _x( \'Event\', \'Custom post type name (singular)\', AI1EC_PLUGIN_NAME ),
            \'add_new\' => __( \'Add New\', AI1EC_PLUGIN_NAME ),
            \'add_new_item\' => __( \'Add New Event\', AI1EC_PLUGIN_NAME ),
            \'edit_item\' => __( \'Edit Event\', AI1EC_PLUGIN_NAME ),
            \'new_item\' => __( \'New Event\', AI1EC_PLUGIN_NAME ),
            \'view_item\' => __( \'View Event\', AI1EC_PLUGIN_NAME ),
            \'search_items\' => __( \'Search Events\', AI1EC_PLUGIN_NAME ),
            \'not_found\' => __( \'No Events found\', AI1EC_PLUGIN_NAME ),
            \'not_found_in_trash\' => __( \'No Events found in Trash\', AI1EC_PLUGIN_NAME ),
            \'parent_item_colon\' => __( \'Parent Event\', AI1EC_PLUGIN_NAME ),
            \'menu_name\' => __( \'Events\', AI1EC_PLUGIN_NAME ),
            \'all_items\' => $ai1ec_app_helper->get_all_items_name()
        );

        // identical to plugin\'s original values        
        $supports = array( \'title\', \'editor\', \'comments\', \'custom-fields\', \'thumbnail\' );


        // this is where the important change is made
        // to get our own rewrite slug:
        // 
        // \'rewrite\' => true
        // 
        // changes to:
        // 
        // \'rewrite\' => array( \'slug\' => \'calendar/event\', \'with_front\' => false )
        // 
        $args = array(
            \'labels\' => $labels,
            \'public\' => true,
            \'publicly_queryable\' => true,
            \'show_ui\' => true,
            \'show_in_menu\' => true,
            \'query_var\' => true,
            \'rewrite\' => array( \'slug\' => \'calendar/event\', \'with_front\' => false ),
            \'capability_type\' => array( \'ai1ec_event\', \'ai1ec_events\' ),
            \'capabilities\' => array(
                \'read_post\'               => \'read_ai1ec_event\',
                \'edit_post\'               => \'edit_ai1ec_event\',
                \'edit_posts\'              => \'edit_ai1ec_events\',
                \'edit_others_posts\'       => \'edit_others_ai1ec_events\',
                \'edit_private_posts\'      => \'edit_private_ai1ec_events\',
                \'edit_published_posts\'    => \'edit_published_ai1ec_events\',
                \'delete_post\'             => \'delete_ai1ec_event\',
                \'delete_posts\'            => \'delete_ai1ec_events\',
                \'delete_others_posts\'     => \'delete_others_ai1ec_events\',
                \'delete_published_posts\'  => \'delete_published_ai1ec_events\',
                \'delete_private_posts\'    => \'delete_private_ai1ec_events\',
                \'publish_posts\'           => \'publish_ai1ec_events\',
                \'read_private_posts\'      => \'read_private_ai1ec_events\' ),
            \'has_archive\' => true,
            \'hierarchical\' => false,
            \'menu_position\' => 5,
            \'supports\' => $supports,
            \'exclude_from_search\' => $ai1ec_settings->exclude_from_search,
        );

        // register the post type with our new settings
        register_post_type( AI1EC_POST_TYPE, $args );

    endif;


}

结束

相关推荐

Only Showing Upcoming Events

在此页面的侧栏中:http://lifebridgecypress.org/our-people, 我有一个即将使用此代码的事件列表。。。<ul id=\"upcoming-events\"> <?php $latestPosts = new WP_Query(); $latestPosts->query(\'cat=3&showposts=10\'); ?> <?php while ($latestPos