Store loop into array

Try to replace $id[$counter] = get_the_id(); with array_push( $id, get_the_ID() ); to collect the post id’s into the $id array. Update: If you also use $ids instead of $id: $args = array( ‘post_type’ => ‘product’, ‘post_status’ => ‘publish’, ‘ignore_sticky_posts’ => 1, ‘posts_per_page’ => 5, ‘orderby’ => ‘date’, ‘order’ => ‘desc’); $ids = array(); $products = … Read more

Why use %d in php when in function

$wpdb->prepare() supports a small subset of the sprintf() arguments. The %d is a placeholder for an integer (not a decimal, that would be %f). Use %d when you want to send a real integer to the database, use %s for strings. An example: $post_id = ‘2’; $prepared = $wpdb->prepare( “SELECT * FROM $wpdb->posts WHERE post_id … Read more

Remove css styles from specific page

You can use conditional tags to target the specific page you need to remove the styles on. You can use is_page() to target a page page (as opposed to another post type) and pass a page ID, slug, title, or no argument to target any page. function wpse_217881_remove_scripts() { // Check for the page you … Read more

How can I set custom order use this function

You will need to add term meta to your categories. In this metafield you will store the string or number that you want to use as a base for your custom order (tutorial). Let’s say you have generated a meta field called my_cat_meta which holds integers that say in which order you want them to … Read more

Missing Author Information

To display the author’s avatar within The Loop use get_avatar() like that: <?php print get_avatar(get_the_author_meta(‘ID’), ’30’, ”, ”, [‘class’ => ‘foo-bar’]); ?> To display the author’s display name within The Loop use the_author(): <?php the_author(); ?> So put everything inside The Loop and then: <?php while (have_posts()) : the_post(); ?> <div class=”row”> <div> <h1 class=”primary-color”> … Read more