400 Bad Request, in wordpress theme development, wp_ajax

The problem is that, you have added extra white space before wp_ajax action. remove space from actions ‘ wp_ajax_my_action’ and ‘ wp_ajax_nopriv_my_action’. because of extra space before ajax request, showing the 400 bad request error. You should use : add_action(‘wp_ajax_my_action’, ‘my_action’); add_action(‘wp_ajax_nopriv_my_action’, ‘my_action’);

How to set up a If is_singular statement?

is_single() and is_singular() are not the correct functions to use here. Your comment mentions that this is being added to search.php, but is_single() and is_singular() will always be false on search.php, because those functions are checking if the current page is a single post or page, but search.php is not. It’s is a list of … Read more

How to create first post, fifth post full width, rest in three columns and so on

<?php get_header() ?> <div class=”container-fluid”> <div class=”row”> <?php $i = 0; while ( have_posts() ) : the_post(); ?> <?php if ($i == 0 || $i % 4 == 0) : ?> <div class=”col-sm-12 blog”> <div class=”row”> <div class=”col-sm-8 p-0″> <?php the_post_thumbnail()?> </div> <div class=”col-sm-4 align-self-center”> <div><h3><?php the_title()?></h3></div> <div><?php the_excerpt()?></div> </div> </div> </div> <?php else: ?> … Read more

cannot echo the_post_thumbnails

Not sure what you’re trying to do, but the problem you’re having with this specific bit of code is that you’re using the wrong function. You want get_the_post_thumbnail() instead. The function the_post_thumbnail() echoes the result of get_the_post_thumbnail(). $args = array( ‘post_type’ => ‘post’, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘posts_per_page’ => 1, ‘category’ => ‘2’, … Read more