This members-only tutorial provides the steps to use Advanced Custom Fields to build a form that logged in users can fill on the front end to submit news i.e., populate a Custom Post Type as drafts in Oxygen.

Admin can then review and publish the entries which can be easily set to appear on the front end using Easy Posts component.

There are various ways in which frontend posting can be set up. I shall cover a few other methods in future tutorials.

Non logged-in visitors will see

Step 1

Let's create the News CPT.

Install and activate Custom Post Type UI.

Step 2

Install and activate ACF or ACF Pro.

Add a new field group titled say, "News Fields".

In this example, since we want the users to enter the URL of their news source, add a Url type field (news_source).

Also, add an Image type field (news_image) that will be mapped later to the featured image of the News CPT entry.

Set the field group to appear on News CPTs.

Step 3

Let's map the image custom field to the CPT entry's featured image.

Install and activate Code Snippets plugin.

Go to Snippets > Add New.

Title: Set uploaded image as featured image for news articles

Code:

This is a premium members-only content.

To view the rest of the content, please sign up for membership ($37/month or $399 one-time).

Already a member? Log in below or here.

Need help implementing a tutorial in your site or want to hire me for custom work?

HIRE ME

Find the article helpful and wish to donate?

DONATE

Comments

For adding code blocks wrap the code in three backticks. Markdown should work.
Provide a URL of your site/webpage if something is not working.
  • Hi Sridhar, Thanks for this great Tutorial! I’m wondering if there is a way to include an email alert to new submissions so clients know when to review drafts?

  • Hello Sridhar, I did try to apply the frontend posting to a second CPT related to a second acf fieldgroup (I set the post status in both templates to ‘publish’)

    But using the filter in the snippet a second time for the related second acf fieldgroup and therein the applied featured image I get an error: “Cannot redeclare acf_set_featured_image() (previously declared in ….”

    Is there a way to get it to work correctly for more than one CPT?

    • I got it by using the same meta key for the applied (featured) image in the second field group, so I have to declare the added filter only once.

  • magnifiercross
    >
    linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram
    %d bloggers like this: