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 | |
/** | |
* Retrieve adjacent post. | |
* | |
* Can either be next or previous post. | |
* | |
* @since 2.5.0 | |
* | |
* @param bool $in_same_term Optional. Whether post should be in a same taxonomy term. | |
* @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. |
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 | |
/* Add {most_common} merge tag. | |
* For assigning a unique quiz result based on most common quiz answer (A, B, C, D, value) */ | |
add_filter('gform_custom_merge_tags', 'custom_merge_tags', 10, 4); | |
function custom_merge_tags($merge_tags, $form_id, $fields, $element_id) { | |
$merge_tags[] = array('label' => 'Most Common Answer', 'tag' => '{most_common}'); | |
return $merge_tags; | |
} | |
/* Replace merge tag with most common value */ |
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 | |
add_filter( "gform_field_choices", "custom_gravity_add_media_credit", 10, 2 ); | |
function custom_gravity_add_media_credit( $choices, $field ) { | |
// If field isn't quiz or radio, and isn't admin | |
if ( ( $field["type"] != "radio" && $field["type"] != "quiz" ) || is_admin() ) { | |
return $choices; | |
} | |
// If isn't an image layout | |
if ( $field["answerLayoutField"] == "list" || !$field["answerLayoutField"] ) { |
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 style="background-color: #cee9f4;"> | |
<!--[if gte mso 9]> | |
<v:background xmlns:v="urn:schemas-microsoft-com:vml" fill="t"> | |
<v:fill type="tile" src="http://static4.businessinsider.com/image/51b5d13369bedde54a000008/peta-goes-the-uncontroversial-route-and-hires-lil-bub-as-a-spokescat.jpg" color="#cee9f4" /> | |
</v:background> | |
<![endif]--> | |
<table id="backgroundTable" style="background-image: url(http://static4.businessinsider.com/image/51b5d13369bedde54a000008/peta-goes-the-uncontroversial-route-and-hires-lil-bub-as-a-spokescat.jpg); background-repeat: no-repeat;" border="0" cellspacing="0" cellpadding="0" width="100%" height="100%" align="center" background="http://static4.businessinsider.com/image/51b5d13369bedde54a000008/peta-goes-the-uncontroversial-route-and-hires-lil-bub-as-a-spokescat.jpg"> | |
<!-- REST OF EMAIL --> |
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 | |
function duffy_custom_post_types_admin_order($wp_query) { | |
if ( is_admin && ( get_query_var('orderby') == 'menu_order title' ) ) { | |
// 'orderby' value can be any column name | |
$wp_query->set('orderby', 'date'); | |
// 'order' value can be ASC or DESC | |
$wp_query->set('order', 'DESC'); | |
} | |
} |
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 | |
function duffy_category_search_logic( $query ) { | |
if ( !isset( $query->query_vars[ 'category_name' ] ) ) | |
return $query; | |
// split cat query on a space to get IDs separated by '+' in URL | |
$cats = explode( ' ', $query->query_vars[ 'category_name' ] ); | |
if ( count( $cats ) > 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
<?php | |
/** | |
* Template hierarchy overrides | |
* Use taxonomy or archive templates for specific cat and search queries | |
*/ | |
function duffy_override_category_template( $template ) { | |
if ( is_category() && ( 'custom-tax' == get_query_var( 'taxonomy' ) ) ) { | |
return get_stylesheet_directory() . '/taxonomy-custom-tax.php'; | |
} | |
if ( is_search() && ( 'custom-type' == get_query_var( 'post_type' ) ) ) { |
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 /* Sort comments by number of thumbs up */ | |
$post_id = get_the_ID(); | |
$comments = get_comments(array( | |
'post_id' => $post_id, | |
"orderby" => "comment_karma", | |
"order" => "DESC" | |
)); | |
?> | |
<?php wp_list_comments('', $comments); ?> |
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
function MYMODULE_views_views_post_build(&$view) { | |
if ($view->name == 'views_name') { | |
if (isset($view->exposed_input['field_geofield_distance'])) { | |
if (isset($view->field['field_geofield_distance'])) { | |
$view->field['field_geofield_distance']->options['exclude'] = TRUE; | |
} | |
} else { | |
if (isset($view->field['field_geofield_distance_1'])) { | |
$view->field['field_geofield_distance_1']->options['exclude'] = TRUE; | |
} |