Showing User’s Post Counts by Custom Post Type in the Author.php?

Here I’ve modified the code from URL you’ve given. function _yoursite_get_author_post_type_counts() { static $counts; if (!isset($counts)) { global $wpdb; global $wp_post_types; $sql = <<<SQL SELECT post_type, post_author, COUNT(*) AS post_count FROM {$wpdb->posts} WHERE 1=1 AND post_type NOT IN (‘revision’,’nav_menu_item’) AND post_status IN (‘publish’,’pending’, ‘draft’) GROUP BY post_type, post_author SQL; $posts = $wpdb->get_results($sql); foreach($posts as $post) … Read more

How to retrieve all wordpress posts (specific type) inside a function in php?

Make sure you’re namespacing the class that is declaring the function, within chapters.php – namespace absf/Chapters Within down-latest-videos.php: use function absf\Chapters\get_down_latest_videos; // This pulls in the function from chapters.php $latest_four_vids = get_down_latest_videos( $post_id ); Your function get_down_latest_videos is expecting one argument to be passed – $post_id. You’re passing it two – $curated_posts and $program_ids. Since … Read more

Create short URL with auto 301 redirect

What you’re trying to do, can be achived by simply using the parse_request hook; no need for the custom rewrite rule and tag. So remove this (and you should flush the rewrite rules — just visit the permalink settings page): add_action( ‘init’, ‘vacature_rewrite_rule’ ); function vacature_rewrite_rule() { … } Then use this modified function which … Read more

How to show all taxonomies within custom post type loop

I’m answering the <?php //echo tax names here ?>: In the loop, you can get the post terms using wp_get_post_terms(): while ($articles->have_posts() ): $articles->the_post(); $terms = wp_get_post_terms( get_the_ID(), ‘topic’, [ ‘fields’ => ‘names’ ] ); Then you can do something like echo implode( ‘ ‘, $terms ); inside the <div> tag: <div class=”masonry__item col-lg-3 col-md-6″ … Read more