Categories
CMS Mastering Development Wordpress

Retrieve all custom field values of a specific custom field metakey as an array, inside WP_Query

I’m building a function into a shortcode to retrieve information relative to a custom post. For the most part, I can retrieve everything I need with the following, despite (probably) not being the most elegant code and a bit long-winded. function gazdept_shortcode($attr){ $a = shortcode_atts( array( ‘posts’ => 1, ‘issue’ => ”, ‘dept’ => ”, […]

Categories
CMS Mastering Development Wordpress

How to ignore posts in pre_get_posts?

I’m using pre_get_posts and looking for a way to exclude posts in the main query. I’m using query_vars to query posts from a specific category and looking for a solution to exclude those posts in the main query. My code: // function to setup query_vars function ctrl_dly_podcast( $query_vars ){ $query_vars[] = ‘ctrl_podcasts_status’; return $query_vars; } […]

Categories
CMS Mastering Development Wordpress

Can query_vars be used to exclude posts in the main query in pre_get_posts?

Is there a way to exclude posts in the main query in pre_get_posts that are already in query_vars? For example: I have three $query_vars that work to get posts depending on the category. Is there a way to have the main query exclude posts in the three $query_vars? Here’s my pre_get_post function: // set up […]

Categories
CMS Mastering Development Wordpress

Custom query give me 404 when paginate

in my site I have "CPT Clients" and each client has "CPT Success Stories", also I have a list of client’s taxonomies, and when access to one of thees, I need to display the stories which client belongs to that taxonomy. My code looks like this: $query_obj = get_queried_object(); $args = array( ‘post_type’ => ‘sky-client’, […]

Categories
CMS Mastering Development Wordpress

Displaying all posts by category and showing content on click

I am building a WordPress site for a composer who has written over 200 pieces of music. Each is a custom post (work), organised by a hierarchical custom taxonomy/category (type – being orchestral, vocal, etc). I need to build a catalogue page in which all works are displayed in lists by type: Orchestral Works: Work […]

Categories
CMS Mastering Development Wordpress

WordPress subcategory archive pagination in custom layout

I have blog with categories and sub-categories and use category.php for archive of main category posts, and added a custom layout for subcategory archive layout as subcategory.php (with a function). In this subcategory archive page, I need a numbered pagination but all I did it returns to 404 Not Found, here my code : function […]

Categories
CMS Mastering Development Wordpress

Looping Through Categories of a CPT

I am trying to create tabs using the Foundations framework, outputting posts from a custom post type called testimonial and filtering them through their assigned custom category called filed-under. What am I doing wrong in my loop? What I Have Working Category tabs appear when new categories are created What is Not Working The posts […]

Categories
CMS Mastering Development Wordpress

Sort custom post type by custom taxonomy

Im using this code to sort my custom post type by one of its custom taxonomies: <?php $valores = get_terms(‘valor’, array(‘order’ => ‘DESC’,)); foreach($valores as $valor) { $posts = get_posts(array( ‘post_type’ => ‘propriedade’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘valor’, ‘field’ => ‘slug’, ‘terms’ => $valor->slug ) ), ‘numberposts’ => -1 )); foreach($valores as $valor) […]

Categories
CMS Mastering Development Wordpress

How to display only the parent owner of an attachment pdf file (using AC and ElasticPress)

I have a CPT (using ACF fields), that have a title, some other taxonomies and a pdf attached file (it’s also an attachment file because i need that Elasticpress search in it). When I do a search, when a word is in the CPT title and in the PDF content, I have 2 results in […]

Categories
CMS Mastering Development Wordpress

How to display only the parent owner of an attachment pdf file (using AC and ElasticPress)

I have a CPT (using ACF fields), that have a title, some other taxonomies and a pdf attached file (it’s also an attachment file because i need that Elasticpress search in it). When I do a search, when a word is in the CPT title and in the PDF content, I have 2 results in […]