WordPress.org

Ready to get started?Download WordPress

Forums

WYSIWYG Widgets / Widget Blocks
[resolved] Compatible with 'advanced custom fields'? (4 posts)

  1. TA003
    Member
    Posted 7 months ago #

    Hi,

    Is it possible to import a custom field that is set in a widget block?

    Any ideas?
    Thanks

    http://wordpress.org/plugins/wysiwyg-widgets/

  2. Danny van Kooten
    Member
    Plugin Author

    Posted 7 months ago #

    Hi there,

    You can use the Advanced Custom Fields plugin to add a custom field to the Widget Blocks. To show this post on (the public section / frontend) of your website you will need some additional code though.

    You can use the ww_content filter hook to add the value of this custom field to the widget content. Are you familiar with PHP and the way WordPress filters work? Your code would look something like this.

    function my_widget_block_content($content, $id) {
    	$field = get_field('my_custom_field', $id);
    
    	$content .= "\nField value: {$field}";
    	return $content;
    }
    
    add_filter('ww_content', 'my_widget_block_content', 10, 2);

    Hope that helps!

  3. TA003
    Member
    Posted 7 months ago #

    Great! Just what I needed!
    This saved me a lot of time!

    Thanks!

  4. Danny van Kooten
    Member
    Plugin Author

    Posted 7 months ago #

    Great, glad I could help!

    PS. I would really appreciate it if you could leave a review on the plugin, once you have a quick minute.

    Thanks!

Reply

You must log in to post.

About this Plugin

About this Topic