Quantcast
Channel: polylang – WordPress.org Forums
Viewing all articles
Browse latest Browse all 11471

qstudio on "[Plugin: Polylang] include/exclude sync of AFC Repeater Fields"

$
0
0

ACF Repeater fields are stored using a variation of the parent field name.

For example - a repeater field called "team_player" with a child item called "team_name" will save each row added in a sequential field called "team_player_0_team_name", "team_player_1_team_name", etc.

A simple way to remove all "team_player" fields might be to set-up the filter like this:

/**
* Remove defined custom fields from Polylang Sync
*
* @since       0.1
* @param       Array       $metas
* @return      Array       Array of meta fields
*/
function pll_copy_post_metas( $metas )
{

    // this needs to be added to the PolyLang Settings page as an option ##
    $unsync = array (
        'team_player'
    );

    #var_dump( $unsync );
    #var_dump( $metas );

    if ( is_array( $metas ) && is_array( $unsync ) ) {

        // loop over all passed metas ##
        foreach ( $metas as $key => $value ) {

            // loop over each unsynch item ##
            foreach ( $unsync as $find ) {

                if ( strpos( $value, $find ) !== false ) {

                    unset( $metas[$key] );

                }

            }

        }

    }

    #wp_die( var_dump( $metas ) );

    // kick back the array ##
    return $metas;

}

Viewing all articles
Browse latest Browse all 11471

Latest Images

Trending Articles



Latest Images