Hey there,
not sure if this is a real bug or a “feature request”, so please feel free to change the category if it doesn’t fit here.
I’m trying to solve a problem with a Query (post-type: attachment) I want to use. Basically I want to create a downloadable “Brand Assets” Section where I have a preview of an image and the title, and on clicking the image I can download it.
However I have problems with outputting the images inside the query-block. The following is my query:
<?php
// The Arguments
$args = array (
'post_type' =>
array (
0 => 'attachment',
),
'post_status' =>
array (
0 => 'inherit',
),
'ignore_sticky_posts' => true,
'tax_query' =>
array (
0 =>
array (
'taxonomy' => 'happyfiles_category',
'field' => 'term_id',
'terms' =>
array (
0 => 5,
),
'include_children' => true,
'removeNoTerms' => false,
'title' => 'Happy Files Brand Assets',
),
),
'orderby' => 'date',
'order' => 'DESC',
);
// The Query
$the_query = new WP_Query( $args );
As you can see I’m using Happy Files for grouping my media files (shouldn’t have any impact on the problem itself, but just to mention it).
The Result looks like the following (as you can see I was able to output the correct “post title”):
Now, there is no way to use the image connected with that attachment “post” as it is not a featured image.
One possibility would be to include the “function return” inside the dynamic image picker, so that i could pass the post_id and use wp_get_attachment_url(get_the_ID());
for example.
A workaround (meanwhile, for anyone facing a similar problem) is to use a code-block and put the following inside of it:
<?php
$src = wp_get_attachment_url(get_the_ID());
echo "<img src='{$src}' class='brand-image' />";
?>
You’re then able to style the image via a Relative-Style Selector inside of cwicly.
As always, hope it’s understandable what I mean - if not, please feel free to ask!
PS: It would be also cool to have some more dynamic options like alt-text and so on (for the wishlist )
Cheers
Wolfgang