Get images by category

‘category_name’ => ‘slides’, that appears to be all that is needed. Not sure if there is a more appropriate way but it is working. The WordPress documentation has to be some of the worst formatted and organised out of any major software documentation. Plenty of information just so hard to navigate.

How to get the current user post and it’s ID?

So digging around a little i couldn’t find a solution where the WP_Query wasn’t used, so i just stuck with the query method, Using WP_Query this snippet will display the latest post that is published by the user that is logged in. $user_id = get_current_user_id(); $args=array( ‘post_type’ => ‘POSTTYPE’, ‘post_status’ => ‘published’, ‘posts_per_page’ => 1, … Read more

Mathematical operations on custom field values? (updated)

use here set type method: add_action(‘init’,’engineCreateRecurringSchedule’); add_action(‘engineRecurringCronJob’,’engineDaysToGoUpdate’); function engineDaysToGoUpdate(){ // Arguments to get published posts with ‘engine’ post type. $engineDaysToGoArgs = get_posts( array ( ‘post_status’ => ‘publish’ ‘posts_per_page’ => -1, ‘post_type’ => ‘engine’) ); // Calling the value of custom field. $engineDaysToGo = genesis_get_custom_field(‘wpcf-engine-days-to-go’); settype($engineDaysToGo, “integer”); // Subtracting 1 from the value. $updatedEngineDaysToGo = $engineDaysToGo–; … Read more

How to Retrieve Post ID of another page

I think this can ve achieved using hidden fields if the single post form Add a field like this in your form <form> YOUR CODE GOES HERE ——————- <input type=”hidden” name=”mypostid” value=”<?php get_the_id(); ?>” /> </form> And the page where this form is posting the data you can get the data for the field mypostid … Read more

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