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 | |
// loop through the sub-pages of your custom post type | |
$childpages = new WP_Query( array( | |
'post_type' => 'work', | |
'post_parent' => $this_page, | |
'posts_per_page' => 100, | |
'orderby' => 'menu_order' | |
)); | |
while ( $childpages->have_posts() ) : $childpages->the_post(); ?> |
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 | |
/* Useful code snippet if you want to display the category title on top | |
* of a featured image on a list of post. | |
* If a post is in more than one category, this snippet | |
* selects the first one. If no cateogry is set, the default category appears. | |
*/ | |
$post_categories = wp_get_post_categories( $post->ID ); | |
// get first category id | |
$first_cat = get_category($post_categories[0]); |
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
add_filter('upload_mimes', 'blm_custom_upload_mimes'); | |
function blm_custom_upload_mimes ( $existing_mimes=array() ) { | |
// add your extension to the array | |
$existing_mimes['vcf'] = 'text/x-vcard'; | |
return $existing_mimes; | |
} |
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
/* This snippet is useful for displaying content in a sidebar for example. If you have | |
* a CPT and a taxonomy, you may want to display all the posts from a specific taxonomy. | |
* The example below pulls posts from a shop CPT, set to "Eat Drink" taxonomy term. | |
*/ | |
<aside class="widget"> | |
<h3>Eat & Drink</h3> | |
<ul> | |
<?php | |
$loop = new WP_Query(array( |
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 | |
$terms = get_terms('category'); //use category or your taxonomy | |
$count = count($terms); | |
//check if there are any terms | |
if ( $count > 0 ){ | |
//loop through each term and query posts. | |
foreach($terms as $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
//To display an image using ACF, one would set the image custom field to image url and call the img as follows: | |
<?php if( get_field( 'field_name' ) ): ?> | |
<?php while( has_sub_field( 'field_name' ) ): ?> | |
<img src="<?php the_sub_field( 'image' ); ?>" alt=""> | |
<?php endwhile; ?> |
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 | |
$args = array( | |
'post_type' => 'your_post_type', | |
'tax_query' => array( | |
'relation' => 'AND', | |
array( | |
'taxonomy' => 'taxonomy1_label' | |
'field' => 'term_id', | |
'terms' => int // this should be an interger - term_ID |
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 id="tabbed-content"> | |
<?php | |
/* Set up tabs at the top using your three categories. | |
* I've created three posts in News, Photos and Videos categories | |
* Both news and photos have featured images. | |
* The videos have a custom field (video) with the youtube embed code. | |
* | |
*/ | |
?> |
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
/* | |
* Remove Prefixes from archive title | |
*/ | |
add_filter( 'get_the_archive_title', function ( $title ) { | |
if( is_category() ) { | |
$title = single_cat_title( '', false ); | |
} | |
elseif ( is_tag() ) { |
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
<ul> | |
<?php | |
$terms = get_terms( 'taxonomy-name' ); | |
foreach($terms as $term){ | |
$term_link = get_term_link( $term ); | |
echo '<li><a href="' . $term_link. '">' . $term->name . '</a></li>'; | |
} | |
?> | |
</ul> |
OlderNewer