Return a numerical function value in Customizer controls

The solution for me ended up being to simply remove the np_post_num() add_action hook altogether, and instead declare get_theme_mod() as the desired variable $option_pg_number. This allowed use of the returned number variable in a separate loop function controlled by $option_pg_number, instead of just printing the returned number value of ‘np_posts_per_page’ on the page. $option_pg_number = … Read more

Increase offset while looping

Yup. What you’re looking for is a smart “counter”. In actuality, your issue is this: You’re trying to avoid duplicate posts. Here’s the popular method to do it. In every file that you run a query, you must add this code: global $duplicated_posts; $args = [ ‘post_type’ => ‘post’, ‘post__not_in’ => $duplicated_posts ]; $query = … Read more

post created but no permalink

Don’t insert into the database directly. Use the proper functions so that the posts are properly created before being inserted into the database. In your case the proper function is wp_insert_post(): wp_insert_post( array( ‘post_type’ => ‘books’, ‘post_title’ => ‘harrypotter’, ‘post_status’ => ‘publish’, ‘post_author’ => 1, ) ); The date field doesn’t need to be set … Read more