Featured image field for questions

8.11K viewsUpdates
0

Hey, is there a way to put a featured image on a question please, just like with a regular WordPress post ? (so that it shows rather than the picture of the person who posted the question for instance).

Also I am trying to use anspress on a template that uses a masonry design and that would be awesome to show every question with its featured image.

Thanks for your answer  🙂

Answered question
0

I’d really like to do exactly this also. @Rahul could you tell us briefly the current best way please?
I’ve seen your (now 3 yr old) gist: Add featured image support in AnsPress question.. not sure if still relevant? If so where to put that code and how to make a form field for it show in the front-end please?
I’ve read your post on the new Form and Validation API. I don’t know where to add the code (I’ve read your page on Overriding and customizing AnsPress, but still not clear… which file to override?). In any case, this seems to be adding completely new fields, rather than simply using the standard WP ‘featured image’ field. I’d prefer to use the standard WP ‘featured image’ field as then the image will show easily in other plugins (as OP mentions).
Thanks, and thanks again for the amazing plugin!

Answered question
0

i’m interesting about this feature…..any news or any idea?

commented on answer

You can add the code I put below, but then you still won’t be able to upload a featured image in the front end…

0

What I did so far : Ok so I found a way to add featured images, also called ‘thumbnails”, in Anspress questions, by doing the following :

Added this code to my theme’s functions.php :

add_action(‘init’, ‘my_custom_init’);
function my_custom_init() {
add_post_type_support( ‘question’, ‘thumbnail’ );

On the Anspress file question.php, added this to display the thumbnail :

<?php

if (has_post_thumbnail()) {
// display the featured image
?>                            <div id=”thumbnailquestion”><?php the_post_thumbnail(); ?>

It works but the admin has to upload images in the backend for them to show has featured images.

What I’d like to do now : I’d like users (and not only the admin) to be able to upload featured images too (the images uploaded through the attachment box would be automatically set as featured images).

 

How I think it could be done : I Imagine there’s something to be changed in the upload form https://github.com/anspress/anspress/blob/b2b86fc8f91b6c96a065ffbf14212e7967610fb9/includes/upload.php but I can’t exactly figure out what. I’ve been trying lots of things myself :/ And yet I’m sure it’s not that hard !

 

Thanks for your help !

0

As a matter of fact it seems it only enables featured images for custom post types, which is not the case in Anspress if I understood well.. Any solution ? Thanks for your answer !
@anspress_team @Rahul    (yes I’m clingy ahah)

0

I think it should be explained somewhere here : https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/#setting-a-featured-image
@Rahul any idea if that would be available in the net update ? 😉