Skip to content

Instantly share code, notes, and snippets.

@ckpicker
ckpicker / gist:4956646
Last active December 13, 2015 18:38
Add this code to your functions.php file. Make sure you upload 'description-count.js' to the following directory: 'YOUR_THEME_DIRECTORY/js/'
// Add our special description count js
add_action( 'wp_enqueue_scripts', 'our_admin_scripts' );
function our_admin_scripts( $hook ) {
global $post_type;
if( tribe_is_community_edit_event_page() ) { // So this only works for posts, would need to edit for events custom post type
$js_dir = trailingslashit( get_template_directory_uri() ) . 'js/';
wp_register_script('our-admin-js', $js_dir . 'description-count.js', array('jquery'), null);
wp_enqueue_script('our-admin-js');
}
}
add_action( 'tribe_events_update_meta', 'my_function', 10, 1 );
function my_function( $event_id ) {
//Do some logic to save the event meta information here
}
function add_custom_title() {
return 'Submit a Seminar';
}
add_action( 'tribe_ce_submit_event_page_title', 'add_custom_title');
function my_function_to_kill_event_save( $post_id ) {
var_dump( $post_id );
exit();
}
add_action( 'tribe_events_update_meta', 'my_function_to_kill_event_save', 10, 1 );
@ckpicker
ckpicker / gist:5013681
Created February 22, 2013 14:13
Exclude Events from Search
// search filter
function custom_search_filter($query) {
if ( !$query->is_admin && $query->is_search) {
$query->set('post_type', array('page','post') );
}
return $query;
}
add_filter( 'pre_get_posts', 'custom_search_filter' );
<span class='tribe-events-calendar-buttons'>
<a class='tribe-events-button-off' href='<?php echo tribe_get_listview_link(); ?>'><?php _e('Event List', 'tribe-events-calendar'); ?></a>
<a class='tribe-events-button-on' href='<?php echo tribe_get_gridview_link(); ?>'><?php _e('Calendar', 'tribe-events-calendar'); ?></a>
</span>
<span class='tribe-events-calendar-buttons'>
<a class='tribe-events-button-on' href='YOUR_URL_GOES_HERE'>Submit an Event</a>
<a class='tribe-events-button-on' href='<?php echo tribe_get_listview_link(); ?>'><?php _e('Event List', 'tribe-events-calendar'); ?></a>
<a class='tribe-events-button-off' href='<?php echo tribe_get_gridview_link(); ?>'><?php _e('Calendar', 'tribe-events-calendar'); ?></a>
</span>
$( document ).on( "click", ".navigateLink", function() {
var anchorName = $(this).attr("ref");
if(anchorName == 'top')
$('html,body').animate({scrollTop: '0px'},'slow');
else
$('html,body').animate({scrollTop: $("#"+anchorName).offset().top - 60},'slow');
return false;
});
@ckpicker
ckpicker / gist:5116597
Created March 8, 2013 13:58
Include jQuery in your theme properly
add_action( 'wp_enqueue_scripts', 'sd_frontend_script_and_style' );
function sd_frontend_script_and_style() {
wp_deregister_script( 'jquery' );
$jquery_url = 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js';
wp_register_script( 'jquery', $jquery_url, array(), null, false );
wp_enqueue_script('jquery');
}
@ckpicker
ckpicker / gist:5119160
Created March 8, 2013 19:33
Conditionally change the page title
<?php if(tribe_is_community_edit_event_page()) { ?>
<h1 class="entry-title">NEW TITLE GOES HERE</h1>
<?php } else { ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php } ?>