How does one flush rules on theme activation or deactivation only?

While the solutions provided here do still work, WordPress has evolved since and does now (since 3.3, I believe) provide direct hooks for theme activation. after_switch_theme will fire on theme activation and switch_theme before deactivating an old theme. Hence the up-to-date answer is: function reflush_rules() { global $wp_rewrite; $wp_rewrite->flush_rules(); } add_action( ‘after_switch_theme’, ‘reflush_rules’ );

Display two post types ordered by two custom fields

My old code was wrong, this is a good one, as I think: function add_custom_post_type_to_query( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( ‘post_type’, array( ‘post’, ‘facebook_events’, ‘event’ ) ); $query->set( ‘meta_query’, array( ‘relation’ => ‘OR’, array( ‘key’ => ‘event_start_date’, //this is from facebook_events post type ‘value’ => date_i18n(“Y-m-d”), ‘compare’ => ‘>=’, … Read more

How to display the rest of categories on Portfolio filterable

if your terms and their slugs are: red, blue, green, yellow. <div data-tag=”<?php echo $terms_portfolio[0]->slug; ?>” would output only the first <div data-tag=”red” if you do <?php $terms_portfolio_slugs = array(); foreach ($terms_portfolio as $tp) { $terms_portfolio_slugs[] = $tp->slug; } $terms_portfolio_csv = implode (‘, ‘,$portfoliotags); ?> <div data-tag=”<?php echo $terms_portfolio_csv?>”> your output would be all of … Read more