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 | |
// E.g. fetch_feed('https://www.example.com/some-feed'); | |
add_action( 'wp_feed_options', 'my_feed_options', 10, 2 ); | |
function my_feed_options( SimplePie $feed, $url ): void { | |
$my_feed = 'https://www.example.com/some-feed'; | |
if ( ! is_string($url) || $my_feed !== $url ) { | |
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
public function filter_post_type_by_taxonomy( $post_type, $which ) { | |
if ( 'my_post_type' == $post_type ) { | |
$taxonomy = get_taxonomy( 'my_taxonomy' ); | |
if ( $taxonomy ) { | |
// Retrieve taxonomy terms | |
$terms = get_terms( $taxonomy->name ); | |
// Display filter HTML | |
echo "<select name='{$taxonomy->name}' id='{$taxonomy->name}' class='postform'>"; | |
echo '<option value="">' . sprintf( esc_html__( 'Show All %s', 'text-domain' ), $taxonomy->labels->name ) . '</option>'; |
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 taxonomy filtering to custom post types | |
* | |
* Original example for one post type, https://generatewp.com/filtering-posts-by-taxonomies-in-the-dashboard/ | |
* | |
*/ | |
function filter_cpt_by_taxonomies( $post_type, $which ) { | |
// Affected post types | |
$post_types = array( | |
'my_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 | |
// Custom WP_Query | |
$args = array(); | |
$my_query = new WP_Query( $args ); | |
if ( $my_query->have_posts() ) : | |
// Number of columns | |
$col_count = 3; | |
// Get post count | |
$post_count = $my_query->found_posts; |