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 post types that have a specific taxonomy (a combination of get_post_types and get_object_taxonomies) | |
* | |
* @author Joshua David Nelson, josh@joshuadnelson.com | |
* @license http://www.gnu.org/licenses/gpl-2.0.html GPLv2.0 | |
* | |
* @see register_post_types(), get_post_types(), get_object_taxonomies() | |
* | |
* @param string $taxonomy Required. The name of the taxonomy the post type(s) supports. |
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 | |
/** | |
* Using wp_dropdown_categories with the post type filter applied. | |
* | |
* @link https://joshuadnelson.com/category-taxonomy-dropdown-filtered-by-post-type/ | |
*/ | |
// Taxonomy dropdown arguments | |
$args = array( | |
'taxonomy' => 'department', |
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 | |
/** | |
* Shortcode to create a list or dropdown link to taxonomy archives | |
* | |
* @author Joshua David Nelson, josh@jdn.im | |
**/ | |
function jdn_taxonomy_list( $atts ) { | |
$a = shortcode_atts( array( | |
'taxonomy' => '', |
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 | |
/** | |
* Filter the post search arguments allow for cross-post-type connections. | |
* | |
* @param array $args the WP_Query arguments used. | |
* @return array | |
*/ | |
function remote_post_search_arguments( $args ) { | |
$translated_post_types = array( 'post', 'page', 'product' ); |
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 | |
/** | |
* Filter the hreflang urls and remove any that are indicative of draft or otherwise non-published content. | |
* | |
* Linked translations that are not yet published will show up as /?p=123 instead of pretty permalink. | |
* | |
* @param array $urls the array of language => url hreflang urls. | |
* @return array | |
*/ | |
add_filter( 'multilingualpress.hreflang_translations', 'filter_mlp_hreflang_translations' ); |
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 | |
/** | |
* Modify query to remove a post type from search results, but keep all others | |
* | |
* @author Joshua David Nelson, josh@joshuadnelson.com | |
* @license http://www.gnu.org/licenses/gpl-2.0.html GPLv2+ | |
*/ | |
add_action( 'pre_get_posts', 'jdn_modify_query' ); | |
function jdn_modify_query( $query ) { | |
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 | |
/** | |
* Check if post type supports an archive | |
* | |
* @param string $post_type post type name | |
* @uses get_post_type | |
* @global object $post | |
* @returns boolean | |
* @author Joshua David Nelson | |
*/ |
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 | |
/** | |
* Use this filter to force jquery to remain in the head section of the page on archives. | |
* | |
* @see https://wordpress.org/support/topic/exclude-jquery-for-other-archive-pages/ | |
* @date 2021-07-02 | |
*/ | |
add_filter( 'stf_jquery_header', 'jdn_archive_header_scripts', 10 ); | |
function jdn_archive_header_scripts( $bool ) { |
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 | |
/** | |
* Check if the page has a gravity form. | |
* | |
* @since 1.0.0 | |
* | |
* @param int $id Post or page id, default to false. | |
* | |
* @return boolean | |
*/ |