Home › Forums › Backend Issues (wp-admin) › Add featured img with URL input form
Hi,
I tried for a moment to put the featured image thanks to an external link. This link comes from google books api (I insert it into an input to have the link). I would like that when the form is submit the image is displayed featured in the post.
I have the script for google api and one form.
Thanks
this is code for take informations about books
$('body').on('click', '#results option', function () {
var id = $(this).val();
$.getJSON('https://www.googleapis.com/books/v1/volumes?langRestrict=fr&q=ISBN' + id, function (bookimg) {
$('#image_livre').html(' <p><img src="' + bookimg.items[0].volumeInfo.imageLinks.thumbnail + '" /></p>');
$('#acf-field_5b72fa2fbe46d').html('"' +bookimg.items[0].volumeInfo.imageLinks.thumbnail+ '" ');
$('#field_5b758f5b7ea02').html('"' +bookimg.items[0].volumeInfo.imageLinks.thumbnail+ '" ');
// $('.#results').click(function () {
// $('.textInMce').html('');
// });
});
And this is the form
<div class="form-group">
<label for="title">Rechercher un livre</label>
<br/>
<input id="researchbytitle" class="form-control" type="text" placeholder="titre"></div>
<p><label for="liste-livres">liste-livres</label>
<br/>
<select multiple class="form-control" id="results"> </select><br/>
<button id="button" type="button">Suivant</button> </p>
<div id="image_livre"></div>
<?php
if ( ! ( is_user_logged_in() ||
current_user_can('publish_posts') ) ) {
echo '<p>You must be a registered author to post.</p>';
} else {
acf_form(array(
'post_id' => 'new_post',
'field_groups' => array(60,71), // Used ID of the field groups here.
'post_title' => true, // This will show the title filed
'post_content' => true, // This will show the content field
'form' => true,
'new_post' => array(
'post_type' => 'Post',
'post_status' => 'publish' // You may use other post statuses like draft, private etc.
),
'return' => '%post_url%',
'submit_value' => 'Submit post',
));
}
?>
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
π Weβre excited to announce we've released Composer support for installing ACF PRO.
— Advanced Custom Fields (@wp_acf) January 31, 2023
π #ComposerPHP fans rejoice!
β¨ Please see the release post for all the details and full instructions. https://t.co/ebEfp61nlR
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.