Attachment Metadata inside of Loop

Here’s the fix. All the attachment info is now being called inside the php using wp_prepare_attachment_for_js and the info will load for each image in the loop, to display in the photo gallery. It works now. <?php $the_query = new WP_Query(array( ‘post_type’ => ‘attachment’, ‘post_status’ => ‘inherit’, ‘category_name’ => ‘arch’ )); while ( $the_query->have_posts() ) … Read more

Querying posts from only one category and exluding the latest post

Try this code global $myOffset; $myOffset = 1; $paged = get_query_var(‘paged’) ? get_query_var(‘paged’) : 1; //Use ‘page’ instead of ‘paged’ if you are on home page $args = array( ‘post_type’ => ‘post’, ‘cat’=> 1, //Selecting post category by ID to show ‘posts_per_page’ => 4, //No. of posts to show ‘offset’ => $myOffset, //Eexcluding latest post … Read more

Popular posts with Varnish ESI

But if the single post page is cached in Varnish, wouldn’t the count stay the same? Yes, if the whole page is cached then the PHP will never get run to update the view count. You’d need an ESI block to call an uncached URL that will increment the view count. Or even an Ajax … Read more

Get Sticky User in user loop based on user role

If you read the code (in version 4.5.2 on line 164-173) you will see that orderby can be an array of values, coupled with order. So you could modify $args like this: $args = array( ‘orderby’ => array( array (‘sticky’ => ‘DESC’), array (‘registered’ => ‘DESC’)), ‘fields’ => ‘all_with_meta’, ); Note that I know nothing … Read more

Get featured image outside the loop using foreach

First you will need to get a list of all available sizes on your site. This function get_intermediate_image_sizes() will do that. You can then pass the results of that to image_get_intermediate_size() along with the post id and <?php $sizes = get_intermediate_image_sizes(); ?> <?php foreach($major_data as $postID) { ;?> <?php $postData = get_post( $postID );?> <?php … Read more

Loop shows post 5 times in a query

the_title() is a template tag which relies on global state. Specifically $post global variable, holding current post instance. While you query a set of posts, you never set up that global state for template tag to use. Though in case you started with get_posts() it might be more convenient to leave global state alone altogether … Read more

WordPress Pages in an Array

Your changes $r[$page->post_name]; to $r[] = $page->post_name; are working fine when I checked them Instead of return $r; use print_r($r) You should see the list of all your pages. Also could you describe why you are using return $r

Loop Posts Outside of WordPress Installation

The error is related to a file called Requests.php, that is not a WordPress file. I don’t see an include or require for this file in your code. Eventually you can add this before require, and check for the wp-load.php path define( ‘WP_USE_THEMES’, false ); But, do this, will not solve the error, may you … Read more

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