shortcode to show custom post types by category

Here is a part in your code that may cause error: $catlist .= ‘<h2>’.the_title().'</h2>’; Try replacing with $catlist .= ‘<h2>’.get_the_title().'</h2>’; Explanation: the_title() echo the title of the post. But in your case you are using it within a function that will return the value. So you have to use get_the_title() instead. Thanks. Note: also there … Read more

Pagination for custom php code

<?php $pod = pods( ‘my_pod’ ); $params = array( ‘limit’ => 15 ); $pod->find( $params ); // Advanced Pagination echo $pod->pagination( array( ‘type’ => ‘advanced’ ) ); // Simple Pagination echo $pod->pagination( array( ‘type’ => ‘simple’ ) ); // Paginate echo $pod->pagination( array( ‘type’ => ‘paginate’ ) ); ?> From Pods documentation.

If Statement – if current post is a child of a post with a taxonomy

This will get all custom post ctp_slug assigned to any term of home-theater taxonomy and return array with posts ID. post__in parameter will limit results to only post with given ID. $args=[ ‘post_type’ => ‘ctp_slug’, ‘posts_per_page’ => -1, ‘offset’ => 0, ‘fields’ => ‘ids’, ‘tax_query’ => [ [ ‘taxonomy’ => ‘home-theater’, ‘operator’ => ‘EXISTS’, ] … Read more

How to query custom post types posts filtered by multiple custom taxonomies through a form selection

Apparently the problem was in the “AND” relation. Code now seems to work: <?php if(isset($_REQUEST[‘submit’])) { $prodotto = $_POST[“prodotto”]; $livello = $_POST[“livello”]; $ruolo = $_POST[“ruolo”]; $stato = $_POST[“stato”]; $args = array( ‘post_type’ => ‘corsi’, ‘posts_per_page’ => -1, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘prodotto’, ‘field’ => ‘slug’, ‘terms’ => … Read more

Setting proper query for multiple custom admin filters

This is my final working piece of code: function wpr_manager_filter($query) { global $pagenow; global $typenow; $current_page = isset( $_GET[‘post_type’] ) ? $_GET[‘post_type’] : ”; if ( is_admin() && ‘properties’ == $typenow && ‘edit.php’ == $pagenow ) { $queryParamsCounter = 0; if (isset( $_GET[‘city-filter’] ) && $_GET[‘city-filter’] != ‘-1’) { $cityId = (int)$_GET[‘city-filter’]; $queryParamsCounter++; } if … Read more