Support » Plugin: W4 Post List » advanced-custom-fields-w4-post-list-bridge

  • Resolved whateverfree2

    (@whateverfree2)


    Hello

    There is a plugin with 32 lines of code name “advanced-custom-fields-w4-post-list-bridge”

    at here https://wordpress.org/plugins/advanced-custom-fields-w4-post-list-bridge/

    But it’s outdated. Could you please take a look and give us the quick fix.

    I understand it’s not your plugin but while there is only few codes and I though you can easy to know why and can help us fix it.
    The author of this plugin even remove himself from WordPress.org and Github so I can’t contact him for help

    <?php
    /*
    Plugin Name: Advanced Custom Fields: W4 Post List Bridge
    Plugin URI: http://github.com/pmill/acf-w4-post-list-bridge/
    Description: This plugin provides a [post_field field="field-name"] shortcode connecting an Advanced Custom Fields field to your W4 Post List list template
    Version: 1.0.0
    Author: pmill
    Author URI: http://github.com/pmill
    License: GPL
    Copyright: pmill
    */
    
    add_filter('w4pl/get_shortcodes', 'w4pl_acf_bridge');
    
    function w4pl_acf_bridge()
    {
        return array(
            'post_field' => array(
                'group' 	=> 'Post',
                'callback' 	=> 'w4pl_shortcode_post_field',
                'desc' 		=> ''
            ),
        );
    }
    
    function w4pl_shortcode_post_field()
    {
        /** @var WP_POST $post */
        global $post;
    
        return get_field('file_url', $post->ID);
    }

    Thanks so much

    • This topic was modified 2 months, 3 weeks ago by whateverfree2.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Shazzad Hossain Khan

    (@sajib1223)

    The function needs to utilize attributes.

    function w4pl_shortcode_post_field($attrs, $content)
    {
        /** @var WP_POST $post */
        global $post;
    
        if (! empty($attrs['field'])) {
            return get_field($attrs['field'], $post->ID);
        }
    }

    Thank you so much for this fix. You saved me!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.