Query custom post types & Taxonomies and list them in a table on a page

You can use term_query in WP_Query: $args = array( ‘post_type’ => ‘all_parks’, ‘posts_per_page’ => -1, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘all_park_categories’, ‘field’ => ‘slug’, ‘terms’ => ‘national_parks’, ), ), ); $all_parks = new WP_Query( $args ); Query all posts with all categories and sort by term or create … Read more

Targeting child pages of custom post types using function?

is_singular only accepts one argument- post type. It’s only for checking if a post is of a certain type(s), not a specific post of that type. Check $post->ID instead- if(is_singular(‘guides’ )&&($post->post_parent==$pid||$post->ID==$pid)) I would also consider using get_queried_object() and/or get_queried_object_id() rather than use the global $post.

Do I need to use another custom post type for 1 post that differs from all of the others?

Here are some options I think you can try: First Option: If you always have that element in your archive page, you can add this element at the end of the list outside the loop. It should look something like this: <?php $query = new WP_Query(array( ‘post_type’ => array(‘team’), ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’, … Read more

get custom post type value in header.php [closed]

I’m observing three problems here. 1- Your anchors do not have a href attribute. As you mentioned, the app_url field is a URL, and should be output in the href attribute of an anchor. So, this is how your anchor should look like: <a href=”https://wordpress.stackexchange.com/questions/293751/<?php echo esc_url( get_field(“app_url’ ) ); ?>”>My Link</a> Note that I’ve … Read more

Add more than one custom post type to wordpress home page post loop

Your second function overwrites the query of the first. It’s not necessary anyway as you can add as many post types to the $query->set line in the first function as you need, like this: $query->set( ‘post_type’, array( ‘post’, ‘first_function’, ‘my-second-post-type’,’another-post-type’ ) ); BTW, is your post type actually called ‘first_function’? Just asking as that’s the … Read more

Filter content in shortcode

The year attribute you added to shortcode [speaker_overview_2017 year=2017] will be available through $atts in this way $atts[‘year’]. I assume, you want to do a meta query and the key is speakers_jaar and the value will be $atts[‘year’]. Please check the following code. When a year is set in shortcode, query will be limited to … Read more

Problem with Apply Filters on URL in meta box filed of custom port type

apply_filters is a function used all throughout WP in many different contexts, your issue here is the specific filter you are applying, which is the_content. the_content filter by default runs on the main post content field, and does all sorts of transformations via a number of hooked functions: wptexturize, convert_smilies, wpautop, do_shortcode, shortcode_unautop, prepend_attachment, wp_make_content_images_responsive. … Read more

Hide custom post type from search based on custom taxonomy

register_post_type() has a argument that you can set to specify which post types you want searched, thus excluded the undesired ones. This is the simplest method, just one line: ‘exclude_from_search’ = true, Alternative to that, you can hook into the search query itself via pre_get_posts and then modify the search, specifying which post types you’re … Read more