Removed custom post type archive page shows blog page

If you are using WordPress 4.4+ (which you should), you can make use of the register_post_type_args filter to adjust the arguments passed to register_post_type() when the post type is registered. In your child theme, you can do the following add_filter( ‘register_post_type_args’, function( $args, $post_type ) { // Make sure we only target the portfolio post … Read more

rewriterule not working

Terminology I think you have some terminology a little mixed up: A URL “rewrite” alters the endpoint of a HTTP request. If http://example.com/param/exam1 really serves content from http://example.com/examples/exam1?get=param, then the former is being rewritten to the latter (though not necessarily visible to the end-user). In the world of URL-rewriting, a “redirect” is a rewrite that … Read more

Best way to change the blog page post type?

You may edit the query using the pre_get_posts action. You can do something like this: add_action(‘pre_get_posts’,’wpse_218948_search_filter’); function wpse_218948_search_filter(){ if( is_page(‘blog’) /* or whatever page it is */ && $query->is_main_query() ){ $query->set(‘post_type’, ‘blog’); # query post type “blog” $query->set( ‘posts_per_page’, -1 ); # display all posts } }

Group by custom field value (start and end times)

try this wich first stack all posts with same times $tabEvent = []; foreach ( $rand_posts as $post ) { setup_postdata( $post ); $start_time = get_field(“start_time”); $end_time = get_field(“end_time”); $index = “$start_time|$end_time”; // store all the posts with same times if (!isset($tabEvent[$index])) { $tabEvent[$index] = []; } $tabEvent[$index][] = $post; } foreach ($tabEvent as $index … Read more

Change post type depending on shortcode

the callback function has 3 parameters and the 3rd is the tag name : add_shortcode( ‘all_faq’, ‘commonFunction’ ); add_shortcode( ‘wordpress_faq’, ‘commonFunction’ ); function commonFunction($attr, $content, $tag) { $cores = [ “all_faq” => “Faq”, “wordpress_faq” => “wp-Faq”, ]; $args = array( ‘post_type’ => $cores[$tag], ‘post_status’ => ‘publish’, ‘posts_per_page’ => ‘-1’ ); // … }