How can I get custom post types to recognize pretty permalink variables?

Building Custom URLs in WordPress discusses how to use Pretty Permalinks to display posts using additional parameters. Jump to the section on Custom Query Vars. That’s where your situation begins to be addressed directly. In particular, you may want to use the example using ‘pre_get_posts‘ to retrieve parameters and adjust the WP_Query using a meta_query, … Read more

Custom Post type shortcodes

For shortcode, you can use add_shortcode function of WordPress theme`s function.php. function shortcode_video_slider() { ?> <div class=”cr-carousel”> <?php $loop = new WP_Query( array( ‘post_type’ => ‘video_slider’) ); //Change video_slider with your custom post name. if ( $loop->have_posts() ) : while ( $loop->have_posts() ) : $loop->the_post(); ?> <div> <?php if ( has_post_thumbnail() ) { ?> <div … Read more

Order Posts in Custom Order

With register_post_type(), you can specify the ‘page-attributes’ => true property, and you’ll get the “menu order” metabox which you see on pages. With this you can custom order your items, where the default is always 0, which means they will always show, even if you don’t set a value. You don’t actually have to set … Read more

Button link display in shortcodes using custom field in ACF

Try this I have recorrected your code, if you have successfully retrieved those two variables $string = ”; $h_query = new WP_Query( $args ); if( $h_query->have_posts() ){ $string .= ‘<div class=”main_history”>’; while( $h_query->have_posts() ){ $h_query->the_post(); $h_button_field = get_field(‘history_button_title’); // used to display the custom field if( !empty($h_button_field) ): endif; $h_link = get_field(‘history_button_url’); // used to … Read more

editing shortcode for custom post type within a plugin

In your code $atts is always $atts = [ ‘category’ => ” ], you cannot use ‘terms’ => $atts, in query parameters $query_args. [litters category=”first_slug,second_slug”] You can assign to ‘terms’ in ‘tax_query’ parameter a string (single category) or an array (multiple category). $args[‘category’] is passed to the shortcode function as string, so you need to … Read more