Support

Account

Home Forums Add-ons Flexible Content Field Flexible Content Row Bookmarks

Solved

Flexible Content Row Bookmarks

  • I have been asked to help with my church’s website. It uses ACF for the staff biography page, via flexible content. We want to establish bookmarks for each flexible content row, so that we can link to that staff member from other pages and posts within the site.

    For example, I have Pastor Steve, Reverend Marshall and Sister Claire. When each of these people are mentioned in other pages and posts on the site, I’d like to have it link to the Staff page, at a bookmark for that person like http://www.church.org/staff#PastorSteve.

    I’m fine with having to establish the link manually, it’s establishing the bookmark that I cannot figure out and there does not appear to be an add-on for creating these bookmarks. Am I missing something? How can this be accomplished?

    Fin.

  • You need to edit the them file that output the flex field. In this template you need to find whatever is wrapping each layout and add an ID to it.

    for example:

    
    <div id="your-id-value-here">
    

    But without knowing how the layout is output in your template or what fields are available in the ACF field group I wouldn’t be able to give more specific help.

  • The hope was that ACF had something built in for bookmarks. Modifying templates requires more advanced knowledge and adds the risk of breaking other things, plus a template update (for non-custom themes) would lose the changes. The suggestion made by John only accounts for one section of the page, not multiple sections as a result of flexible content. – Thank you for the input, though.

    I ended up creating a text field in my flexible content, so that I could define what would be used for the bookmark for each person’s content. I then modified the template to pull the text field’s content and apply it to the flexible content loop ID property. Fortunately our theme and templates are custom, so I don’t have to worry about losing changes in an update.

    <?php
    	$staffname = get_sub_field('name');
    	$staffbiog = get_sub_field('bio');
        $staffmark = '"' . get_sub_field('bookmark') . '"';
    ?>
    <section class="block flex_detail" id=<?php echo $staffmark; ?>>
    	<article class="flexcon">
    		<div class="flexentry">
    			<header>
    				<h4><?php echo $staffname; ?></h4>
    			</header>
                <?php echo $staffbiog; ?>
    		</div>
    	</article>
    </section>
  • Most themes using ACF are custom and don’t get updated. There is nothing built in to ACF that to modify the content and markup of your a site. There are a few themes that use ACF, but most developers that use ACF are building custom themes.

    The solution you have is what I was beginning to suggesting, but without the details I was asking for I could only go so far.

    The only difference in what you did and what I would have suggested is that I probably would have used an existing field

    
    $staffname = get_sub_field('name');
    $id = preg_replace('/[^a-z0-9]+/' '-', strtolower($staffname));
    
Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Flexible Content Row Bookmarks’ is closed to new replies.