Unable to get wp_get_attachment_url to show

That’s not going to work, instead just use wp_get_attachment_image_src , it takes a size parameter. // get the $attachment_id $attach_stuff = wp_get_attachment_image_src( $attachment_id, ‘full’); var_dump($attach_stuff); You will be returned an array fo values to work with: [0] => url [1] => width [2] => height [3] => boolean: true if $url is a resized image, … Read more

Why am I getting and error from wp_get_attachment_image_src?

PHP does not support the function array dereferencing, which you want to do. In simple words – you can’t treat function as array. What you should do is: <div id=”canvas” class=”plan-page” style=”background-image: url(‘<?php $image_src = echo wp_get_attachment_image_src( stripslashes($options[‘sitePlan’]), ‘full’); if ( is_array($image_src) ) echo $image_src[0]; ?>’);”></div> Or to be even more correct: <?php $image_src = … Read more

How can I get url from image tag in feed with fetch_feed?

I found alternative solution for my problem. Instead of using fetch_feed, I used DOMDocument in PHP. This is my code <?php $rss = new DOMDocument(); $rss->load(‘http://techdaily.vn/feed/’); $feed = array(); foreach ($rss->getElementsByTagName(‘item’) as $node) { $item = array ( ‘title’ => $node->getElementsByTagName(‘title’)->item(0)->nodeValue, ‘link’ => $node->getElementsByTagName(‘link’)->item(0)->nodeValue, ‘image’ => $node->getElementsByTagName(‘image’)->item(0)->nodeValue, ); array_push($feed, $item); } $limit = 1; for($x=0;$x<$limit;$x++) … Read more

Retrieve First Image Function

Hmm that looks familiar 😉 You are missing the orderby parameter, in this case you want to order by menu_order. Also there is no reason to query all the data using -1 when you just want one image returned so instead use 1. $attachments = get_children( array( ‘numberposts’ => 1, ‘order’=> ‘ASC’, ‘post_mime_type’ => ‘image’, … Read more