get_post orderby not working in plugin

You don’t get any ordering, because you are making multiple get_posts() calls and only retrieve a single post in each of them. You cannot order a single post. 🙂 You need to get rid of outermost loop and just pass a set of IDs (that would be your $instance[‘data’]) to retrieve via single get_posts() call.

Order post by taxonomy

It is quite easy to achieve this. Your answer is usort() FEW NOTES: Before we code, just a few notes Requires PHP5.4+ due to the use of the short array syntax ([]). If you have an older version, you should really upgrade as older versions are a real security threat as all older versions prior … Read more

Sort posts according to date

Here’s how I’d attack your problem (in fact I think I’ve written code like this in the past, but I can’t find it at the moment): $blogs = array( 4, 1 ); $all_posts = array(); foreach( $blogs as $blog ) { switch_to_blog( $blog ); $args = array( ‘posts_per_page’ => 10, ‘orderby’ => ‘date’, ‘order’ => … Read more

Loop through incrementing custom fields

How can I loop through the fields and display the content without having to deplicate it? This for loop will cycle through the four field names to avoid duplication. <?php for ($i=1; $i<=4; $i++) { $fieldName=”featured_content_” . $i; $featuredContentPostID = get_field($fieldName)->ID; $selectedFeaturedContent = get_post( $featuredContentPostID ); ?> <li> <a href=”https://wordpress.stackexchange.com/questions/204839/<?php echo esc_url( get_permalink($featuredContentPostID) ); ?>”> … Read more

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