Support

Account

Home Forums General Issues Repeater field into a page?

Solved

Repeater field into a page?

  • Hi all,

    I am looking to see if it is possible to create wiki pages using the ACF field. The only difference is I want to do it all on one custom post type.

    So instead of each “wiki page” being a post, there would be one post for the main wiki of that subject and then you can create additional pages using a repeater field or similar?

    Then it would be (if possible) to set a url for that field which can be accessed and also add it into a menu.

    I have no idea where to start on this so it would be extremely useful for your help!

  • Hi @kyon147

    If you have only small amount of the wiki pages and you don’t need the pretty permalink (pretty permalink: http://example.com/link-to/the-page/, plain permalink: http://example.com/?linkto=thepage), then you can do it.

    What you need to do is to get the URL parameter in the plain permalink and use it to show the row you want. Maybe something like this:

    // Current URL: http://example.com/?linkto=thepage
    
    // Get the slug of the current page ('thepage')
    $page_name = (isset($_GET['linkto'])) ? $_GET['linkto'] : false;
    
    // If the slug exists
    if( $page_name ){
        
        // Get the repeater data
        $repeater = get_field('wiki_repeater_name');
        
        // We need to set the wiki slug as an array key, so we need a second
        // variable to hold the new repeater data
        $modified_repeater = array();
        
        // loop through the repeater and set the array key
        foreach( $repeater as $item ) {
            $modified_repeater[$item['wiki_slug_subfield']] = $item;
        }
    
        // Show the data
        echo $modified_repeater[$page_name]['wiki_title_subfield'];
        
        // user print_r() to see how the data looks like:
        // print_r($modified_repeater);
    }

    That being said, I still suggest you use a post for each wiki page instead.

    I hope this helps πŸ™‚

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.