WP All Export ACF image url - wordpress

In my posts i have ACF field image (array). I can't understand how export image url in xml file by function editor. Help me please
enter image description here

From plugin documentation:
ACF fields are automatically detected by WP All Export. To customize
your export file, select fields from Available Data > ACF and drag and
drop them into the export editor.
Image fields export the URL to the image or file. Multiple images or
files in a single field will be separated by the pipe ( | ) character.
https://www.wpallimport.com/documentation/export-acf-media-fields-to-csv-or-xml/
In other words, looks like you don't have to do anything special - just drag and drop as per the screenshot on the documentation page.

Related

How to allow only 1 attachment for each post and make it a requirement for each post?

I am currently attempting to configure the settings of attachments to make it required and only one attachment attached to a post but all my changes did not have any good results.
I have looked into adding an action to attachment_register function and some documentation about attachments in Wordpress but still no positive results.
Personally, I would go with the ACF (Advanced Custom Fields) plugin to accomplish this.
You can use the plugin add a new required media upload (picture/file) meta field for posts.
In the settings for this new Custom Field group, you also use the plugin to remove the default "featured image" field from the edit post screen, to force the user to use your new required media upload function.
All that said, you will probably need to make adjustments to your theme template files to use the ACF functions to display the data on your site. This will probably be pretty straight forward as long as you have ability to alter you theme template files.
Hope that helps!
Building on Mike C's answer in regards to using ACF (Advanced Custom Fields) with a step by step walkthrough of how to achieve such a thing.
Install the Advanced Custom Fields Plugin
Once Activated you will see a new section in the Wordpress Left Menu
Click Custom Fields
First we need a field group, click Add New
Name this something relevant such as "Page Attachment"
Now Click Add Field and Fill out the fields, example below:
Field Label: Upload Attachment
Field Name: page_attachment
Field Type: File
Return Value: If you want someone to click a link to download, select File URL
Scroll Down To The Section Titled Locations
You mentioned that this should be on posts so I would recommend the below selections:
Post Type -> Is Equal To -> Post
Click Save/Update
Go To A Post, you will now see a button that reads Add File, you cannot update/create a post without having a file attached.
This is the admin work completed now we need to make the file appear in the post.
Now if you want the file to appear at the end of the post, under the header or even in the sidebar that is fine. Simply add the following code:
<p><a href="<?php the_field('page_attachment');?>" title="<?php the_title();?>">
Download Attachment
</a></p>
Obviously this is just a link that it echos, so this could be added to an image to make it seem a little more stylish, it's up to you. But this is the simple way of adding a file.
Now if you wanted to add this into the page content midway, you would either need to make a shortcode function to display it. Or you could add something like:
Download Now
And then add the following to the bottom of your post:
<p id="attachment"><a href="<?php the_field('page_attachment');?>" title="<?php the_title();?>">
Download Attachment
</a></p>
This means, whenever some clicks on the link that takes them to #attachment, it will jump them down to the bottom of the post where the download link is.
Any questions, let me know.

Passing Custom Post Field values to javascript

Is it possible to pass Custom Post variables into a javascript file? What I am trying to do is to grab the user-entered URLs of several images to create a gallery slideshow. For example the user:
Enters a URL of an image in a Custom Post Field with the value Image1, then again the user enters a URL of an image in another Custom Post Field with the value Image2.
The values of image1 and image2 are passed into a javascript file (slideshow) with the following code which basically holds the slides:
images = ['http://www.hdwallpapersimages.com/wp-content/uploads/2014/01/Winter-Tiger-Wild-Cat-Images.jpg', 'http://3.bp.blogspot.com/-rZmCIp0C-hQ/Tx6aCFeweoI/AAAAAAAAAnQ/WqIEVBTIzRk/s1600/Cool-Tiger-Wallpaper-1920x1080-HD.jpg'];
What i need is to replace the 2 URL above with 2 variables that actually hold the URL of the images.
Thank you for the reply.
Why don't you create your JavaScript dynamically with PHP?
In that way you can read your $_POST field and create a JS array.
Else if you can't write JS with a server side script you can write into a file with the PHP script which read the POST and then read your file with JS.. But in that way anybody can read it!
Hope it helps and sorry for my English!
Bye!

Wordpress Widget plugin and input file

I am writing a widget plugin for Wordpress and I want to insert an input tag:<input type="file"> to browse for a pattern in my widget plugin admin panel; but I have problem to save its value.
It seems that <input type="file"> doesn't work in widget plugins. Is it correct? Are there any other ways to browse a file from the admin panel?
I made it using combination of arbitrary file input and hidden input for image path. Here're the steps:
create hidden field that will be saved and dummy file input
bind change event to file input (I'm using jQuery)
on change collect FormData object and send it via ajax to ajaxurl
add action('wp_ajax_hook', 'my_callback_func') in functions.php, where hook = your action
move uploaded file(s) to upload dir
return file path from my_callback_func
fill hidden field with file path on ajax success
display uploaded image for user, so that he konws upload was successful (optional)
PROFIT!!! Now you can save you form
I will not post code snippets here, cause they are rather trivial for most developers

How to hide a custom field in wordpress

I m working on my website and I'm trying to get custom fields to work. I have a page with some custom fields added. When I add this php code
<?php the_meta ?>
to my single.php file, a custom field 'WP-Prosper' automatically displayed to my post with its value like this.
WP-Prosper: a:2:{s:12:"remove_thumb";s:0:"";s:11:"video_embed";s:0:"";}
File Type: .IPA
I didn't give any value to this custom field. How can I remove it from my custom field section?
the_meta() is perhaps too blunt an instrument: it simply shows all custom fields for the post.
You'll have complete control over your output if you specify which meta keys exactly you want to output. Take a look at http://codex.wordpress.org/Function_Reference/get_post_meta
e.g. <?php echo get_post_meta($post->ID, 'my_meta_key'); ?>
Use Delete Custom Fields plugin to remove your unwanted custom field.
Or you can manually delete it from postmeta table of WordPress database.
Cheers!!!
UPDATE
Manual removal of postmeta from phpmyadmin
*Important: before updating, please back up your database and files.
Go to your database’s phpmyadmin.
In the left column look for “wp_postmeta”
Click on Browse at the top of the page.
Find the Sort by key: drop-down menu and choose “option_name
(ascending)” or “option_name (descending)”
Under the “option_name” column, look for the name of the Custom
Field that you want want to delete.
Click the red X in that row to delete the Custom Field. Repeat for
each instance of that particular Custom Field you wish to get rid
of.
In WordPress, open up a new post and scroll down to Custom Fields.
Look in the drop down menu to make sure that Custom Field is now
gone.

WordPress Media as a Custom Post Type

I am building a WordPress website that will allow members to upload media such as videos, images, etc. They will do this on a public form at for example: domain.com/upload
The form will ask for a Title, a brief summary, show some categories to choose from, and finally a file uploader. The user will then be able to submit the form and it will appear on the site as a post but instead of being just text it is a piece of media.
I have created a custom post type and all seems to be fine, the problem I have is how to deal with the media upload, as the default WP method is to upload an item and then manually insert it into the post (and you can have as many inserted as you like). Where as I want users to be only able to upload one file per post and not have to insert the file into a post because the file itself is the post. They will also be able to upload a featured image.
Any ideas on how I can develop this? Thanks.
You could use WP upload methods to upload your file to the server. Then (depending on your upload's media type) you would insert HTML representation of the file into the post (e.g. parse a text file, create tag for image or embed a video).
If you want to see some working example, please let me know. I just outline the flow:
wp-handle_upload() to physically upload a file
wp_update_post() or wp_insert_post() depending on whether you're creating a new user post or editing existing one. Both methods require one argument - Post object. That's where you put your content (as a post_content field of course) and post data

Resources