Support

Account

Home Forums ACF PRO Polylang & Location Front Page

Solving

Polylang & Location Front Page

  • Hi,

    I have a field group that is displayed on the front page, meaning the location rule is “Page type is equal to front page”. Now when I edit a front page that is not in the default language my ACF fields don’t show. Presumably because ACF only checks for the value of the page_on_front database field. Has anyone else run into this?

    Thanks,
    Franz

  • Hi @fthues

    ACF works well with WPML, but I’m not sure about Polylang. This page should give you more idea about it: http://www.advancedcustomfields.com/resources/multilingual-custom-fields/.

    You can also specify the id of the original post like this:

    $field = get_field('field_name', 99);

    Where ’99’ is the id that has the custom fields.

    I hope this helps.

  • This reply has been marked as private.
  • Was there an answer to this? I’ve got the same issue. The problem is not getting the value in front end, the field doesn’t show up in backend on the front page of other languages.

  • Hello!

    page_on_front has still one value.

    Could you help me to hook ACF to display all fields meant to be on the front page editor?

  • It is possible to hook page_on_front option during acf/location/rule_match/page_type

    
    <?php
    
    class ACF_Page_Type_Polylang {
    
        // Whether we hooked page_on_front
        private $filtered = false;
    
        public function __construct() {
    
            add_filter( 'acf/location/rule_match/page_type', array( $this, 'hook_page_on_front' ) );
        }
    
        public function hook_page_on_front( $match ) {
    
            if ( ! $this->filtered ) {
                add_filter( 'option_page_on_front', array( $this, 'translate_page_on_front' ) );
                // Prevent second hooking
                $this->filtered = true;
            }
    
            return $match;
        }
    
        public function translate_page_on_front( $value ) {
    
            if ( function_exists( 'pll_get_post' ) ) {
                $value = pll_get_post( $value );
            }
    
            return $value;
        }
    }
    
    new ACF_Page_Type_Polylang();
    
Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘Polylang & Location Front Page’ is closed to new replies.