This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// not for the Events Calendar posts but for an Events CPT or sommething similar that uses ACF fields for dates. | |
// example from https://idelic.com/resource-type/events/ | |
<?php | |
$today = current_time('Ymd'); | |
$post_query_args = array( | |
'post_type' => 'resources', | |
'posts_per_page' => -1, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// example from https://airetechnologies.com/, used here on resources CPT to filter by taxonomy resourctype | |
function filter_cars_by_taxonomies( $post_type, $which ) { | |
// Apply this only on a specific post type | |
if ( 'resources' !== $post_type ) | |
return; | |
// A list of taxonomy slugs to filter by | |
$taxonomies = array( 'resourcetype' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// see example https://www.carnegiehero.org/heroes/latest-award-announcements/press-releases/ | |
<?php | |
$oldest = get_posts( 'post_type=post&post_status=publish&posts_per_page=1&order=ASC' ); | |
$oldest_date = $oldest[0]->post_date; | |
$first_date = date('Y', strtotime($oldest_date)); | |
$todays_date = date('Y'); | |
$year_range = range($todays_date, $first_date); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// enclose svg in div with class svg-container | |
// in example below, 599/859 is the svg's height/width | |
$(window).on("resize", function () { | |
var myWidth = $('.svg-container').width(); | |
var myHeight = (myWidth * 599/859); | |
$('.svg-container svg').css('width', myWidth + 'px'); | |
$('.svg-container svg').css('height', myHeight + 'px'); | |
}).resize(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="l-main-col"> | |
<table class="parts-table"> | |
<tbody class="facetwp-template"> | |
<?php | |
$termid = get_queried_object()->term_id; | |
$args = array( | |
'post_type' => 'product', | |
'posts_per_page' => 18, | |
'facetwp' => true, | |
'paged' => $paged, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// https://generatewp.com/filtering-posts-by-taxonomies-in-the-dashboard/ | |
// Allow sorting by taxonomies in admin | |
function filter_officers_by_taxonomies( $post_type, $which ) { | |
// Apply this only on a specific post type | |
if ( 'team' !== $post_type ) | |
return; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="site-branding"> | |
<a href="<?php echo esc_url( home_url( '/' )); ?>" rel="home"> | |
<img class="site-logo" | |
src="<?php bloginfo('template_directory'); ?>/assets/img/dist/branding/site-logo.png" | |
srcset="<?php bloginfo('template_directory'); ?>/assets/img/dist/branding/site-logo.png 1x, <?php bloginfo('template_directory'); ?>/assets/img/dist/branding/[email protected] 2x" | |
width="289" | |
height="67" | |
alt="<?php bloginfo( 'name' ); ?>"> | |
</a> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$the_query = new WP_Query( array( | |
'post_type' => 'post_type_name', | |
'tax_query' => array( | |
array ( | |
'taxonomy' => 'taxonomy_name', | |
'field' => 'slug', | |
'terms' => 'taxonomy_term', | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Get the first category on a single post by slug or name. | |
$category = get_the_category(); | |
$currentcat = $category[0]->cat_ID; | |
$currentcatname = $category[0]->cat_name; | |
$currentcatslug = $category[0]->slug; | |
echo $currentcatname; | |
echo $currentcatslug; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Get the first term on a single post by slug or name. | |
$tax = 'taxonomy_name'; | |
$terms = get_the_terms( get_the_ID(), $tax ); | |
$term_slug = array(); | |
$term_name = array(); | |
if ( $terms && ! is_wp_error( $terms )) { |
NewerOlder