Skip to content

Instantly share code, notes, and snippets.

View vungocthien's full-sized avatar
🏠
Working from home

Thien Vu vungocthien

🏠
Working from home
View GitHub Profile
@vungocthien
vungocthien / wordpress-add-categories-to-a-custom-post-type
Last active October 9, 2017 06:15
WordPress - Display custom post types on the same category page as your default posts
add_filter('pre_get_posts', 'query_post_type');
function query_post_type($query) {
if( is_category() ) {
$post_type = get_query_var('post_type');
if($post_type)
$post_type = $post_type;
else
$post_type = array('nav_menu_item', 'post', 'your-custom-posttype'); // don't forget nav_menu_item to allow menus to work!
$query->set('post_type',$post_type);
return $query;
@vungocthien
vungocthien / custom-past-events.php
Created October 24, 2019 04:34 — forked from jo-snips/custom-past-events.php
The Events Calendar: Custom Query for Past Events
<?php
global $post;
$get_posts = tribe_get_events(array('posts_per_page'=>-1, 'eventDisplay'=>'past') );
foreach($get_posts as $post) { setup_postdata($post);
?>
<?php if ( has_post_thumbnail() ) { ?>