How to display the pagination in my post list? [duplicate]

You’re having pagination issues because you’re using a custom query and both previous_posts_link and next_posts_link use the default query to calculate and display the pagination. This problem is explained in-depth in both this and this answers to similar questions. If the only reason for you to be using a custom query is for defining the … Read more

How to make certain posts not appear on the main page, but instead only a newly created category(in the menu section)

You can exclude posts in the “Reviews” category from the main feed using the pre_get_posts hook and some WP_Query knowledge: add_action( ‘pre_get_posts’, function ( $wp_query ) { if ( ! is_admin() && $wp_query->is_main_query() && $wp_query->is_home() ) { $wp_query->set( ‘category__not_in’, 4 ); } }); Here I’ve assumed the ID of the category is 4, you’ll need … Read more

how to fetch posts from Api in chunks or parts?

You’d probably want to wrap what you’ve done up there into a function and do something like. for ( $counter = 0; $counter <= 1906; $counter += 20) { $responseURL = ‘https://api.hubapi.com/content/api/v2/blog-posts?hapikey=’ . $apiKey . ‘&archived=false&limit=20&offset=” . $counter; $response = wp_remote_get($responseURL, $getArgs); process_API_results($response); $restcounter++; if($restcounter == 6) { // works out to 120 posts then … Read more

wp_insert_post not inserting post

I recommend changing the form tag to: This will ensure that the form submits to the same page it is on. Also post_title and post_content are required, so the insert will fail if either of those values are blank or missing. (https://developer.wordpress.org/reference/functions/wp_insert_post/)

Change WordPress names duplicate titles (url)

For details please see this answer : Remove Dash/Hyphen From WordPress CustomPosttype Permalink In your functions.php : function no_dashes($title) { return str_replace(‘-‘, ”, $title); } add_filter(‘sanitize_title’, ‘no_dashes’ , 9999); For particular type of post : function no_dashes( $slug, $post_ID, $post_status, $post_type ) { if( $post_type == “page” ) { $slug = str_replace( ‘-‘, ”, $slug); … Read more

show loop id post , only first id can read

You are getting the option “blog-featured-post”, which apparently returns two posts. Then, for each of these posts, you are making a query. Only the second one is actually used, since your if ( $q->have_posts() ) is outside of the loop. This query only has one post, since you use the post ID with the post__in … Read more

Checking if a post contains an html tag

You could try something like this if you are checking the content in the main loop. $content = get_the_content(); preg_match_all(‘/(<img .*?>)/’, $content, $img_tags); if (!empty($img_tags)) { // Post content contains images, do something! } // Check for links and do something if you have matches