Even with PHP plugin get_posts not working in widget area

Tuns out it needed: global $post Complete working code: <div class=”aboutgridcont”> <ul class=”about-us-grid”> <li> <?php global $post; $posts = get_posts(‘post_type=employee&orderby=rand&numberposts=16′); foreach($posts as $post) { ?> <img class=”headshot” src=”https://wordpress.stackexchange.com/questions/196622/<?php the_field(“headshot’); ?>”> <?php } ?> </ul> </div>

This wp_query will not return any posts and only seems to work with post_status inherit?

This part require(‘./wp-blog-header.php’); is all kinds of bad idea. And if your file is indeed in plugin folder then header isn’t even in that location. Custom loads of WordPress core are brittle and the technique is typically only justifiable for performance reasons. It would be better to structure your endpoint via creating actual rewrite endpoint, … Read more

numberposts not responding to wp_reset_postdata()

@Milo’s answer worked perfectly (see comment above). if (in_array($post->ID, $do_not_duplicate)) continue; meant that duplicate posts were still being counted in the loop, though not being displayed. To fix, remove this line, and exclude duplicate posts from the query with this argument: ‘post__not_in’ => $do_not_duplicate. Thank you @Milo for your swift and succinct response.

offset and max_num_pages in pagination gallery

If you want max_num_pages, you need to use WP_Query instead of get_posts. You can then use $your_query_object->max_num_pages in your code. offset and paged don’t work together, because both of them ultimately set LIMIT in the MySQL query. offset query parameter will always override paged. If you want to offset the results, you need to do … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)