Support

Account

Home Forums General Issues Saving data in fields and accessing from PHP

Unread

Saving data in fields and accessing from PHP

  • Hi,
    I am migrating my site from an obsolete theme.

    As part of the old site’s functionality we have a weekly newsletter which needs to access a set of parameters like “Title”, “Sub-title”, “No of posts”, “Header Image” etc. I had to build the code which generates this in PHP with inline CSS because this goes out via a Mailchimp email and the format is heavily table-based.

    I used to use a WP plugin called “Custom Website Data” which is no longer available and this allowed the storage of these parameters, and assigned shortcodes to them. I could then reference these codes in the PHP code which formatted and populated the newsletter.

    For example one entry in the Custom Data might be:

    Reference Shortcode Output
    Subtitle_Text [cwd ref=”Subtitle_Text”] This would be the output of the custom field

    In the PHP code I could then use this code as follows:
    $sub_title_text = str_replace(“\\”,””,sanitize_text_field(do_shortcode(‘[cwd ref=”Subtitle_Text”]’)));

    The key requirement was for the Newsletter Editor, who is non-technical, to be able to easily access and change the Output of the various reference fields via the WP Dashboard.

    Since the Custom Web Data plugin is no longer available, I am trying to do a similar thing with ACF but am getting a little stuck. Can anyone please advise whether I can use ACF in this way, and what the best approach might be?

    Many thanks in advance.

    John

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.