Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Using ACF to show employees, but how to show details of an employee?

  • Hi,

    I’m currently using GeneratePress Pro, GB Pro, and ACF for our website.

    I have successfully set up a query loop and integrated ACF to display our employees on our staff page, utilizing a custom post type for employees. Additionally, I have implemented a URL rewrite to format our links as follows: https://<domain>/our-team/employees/<employee-name&gt;.

    And probably also good to know that I’m using WPML. In the URL I mentioned “our-team” this English, but I also need it for another language Dutch and then the sub part of the slug is “ons-team”.

    I’m now looking to enhance our site by adding a general profile page for each employee that includes more detailed information such as phone numbers, specializations, and biographies.

    Could you please guide me on how to create these detailed profile pages using the tools and setup we have?

    Thank you,
    Henk

  • Hi there,

    Could you please guide me on how to create these detailed profile pages using the tools and setup we have?

    You can create a block element – content template and assign it to the single CPT.

    In the content template, you can pull the data from ACF.

    Let me know if it’s clear 🙂

  • Hi Ying,

    Thank you for your previous response. I still need further clarification to fully understand your explanation. Here’s a detailed description of what I am trying to achieve and the specific area where I need help.

    Currently, I am able to retrieve data using Advanced Custom Fields (ACF) and incorporate this data into dynamic blocks within templates, specifically for populating hero sections with the correct text. This part of the process is clear to me.

    However, I am encountering a challenge on the page that lists all employees. On this page, I utilize a query block coupled with dynamic blocks to display the employee information. My question is: how can I set up a redirection from this overview page to a page dedicated to an individual employee?

    I have attempted to explain this issue in more detail in the private sections with URLs.

    Could you provide guidance on how to achieve this redirection effectively?

  • My question is: how can I set up a redirection from this overview page to a page dedicated to an individual employee?

    If you set any headline block’s link source to single post in the query loop, the link should take you to the single CPT. I see that you’ve done that already.

    But if the issue is related to permalinks, we do not have control over that, you might need to do some more research on this.

  • Thanks, I solved it.

    The next question is that I need some assistance to make the email address that is stored in a ACF field clickable. I kan show it with an Headline block but how kan I make it clickable?

    For email address I need to prefix it with mailto:, phone numbers with callto: and for URLs with https://. How can I do that?

  • Based on other examples, I tried to write two filters, can this appraoach work?
    Or is there another method?

    And how can I fix the naked URLs?
    See the private information for the screenshot I made that shows the naked URLs.

    add_filter( 'generateblocks_dynamic_url_output', function( $url, $attributes ) {
        $class_name = isset( $attributes['className'] ) ? $attributes['className'] : '';
    
        if ( $class_name === 'email' ) {
            $url = 'mailto:' . $url;
        } elseif ( $class_name === 'tel' ) {
            $url = 'tel:' . $url;
        }
    
        return $url;
    }, 10, 2 );
    
    add_filter( 'render_block', function( $block_content, $block ) {
        // This regex now also includes checking and avoiding duplicate target="_blank"
        $pattern = '/<a\s+(?!.*?\btarget="_blank\b)[^>]*href="(mailto:|tel:|https:\/\/)"/i';
        $replacement = '<a target="_blank" rel="noopener noreferrer" $0';
        $block_content = preg_replace($pattern, $replacement, $block_content);
    
        return $block_content;
    }, 10, 2 );
  • Don’t think the 2nd code is needed.

    However, if you are editing a content template for single CPT, I don’t think the code is needed, as the feature is built-in, you can select email or phone as the link type in the dynamic data option:
    https://app.screencast.com/6UuYiaUQFVvBm

  • yes, that works!

    Thank you Ying.

  • No Problem 🙂

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