• HI

    (@peterturner849)


    Hello guys,

    Can somebody help me how I can create a Post Title(H1) using two or more custom meta fields, also a shortcode of that function, so can use that shortcode in Element / Page builder.

    Example Title: How to cook Indian Chicken Biriyani.

    Above – 1. How to cook (Should be Fixed in every title)

    2. Indian (Custom meta field, so I can put anything from post editor)

    3. Chicken Biryani (Custom meta field, so I can put any recipe I want in post editor)

    The title should be within (h1) tag.

    also I want to put the title using shortcode in Single post Page builder.

    • This topic was modified 1 year, 10 months ago by HI.
    • This topic was modified 1 year, 10 months ago by HI.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    I’m not so sure that titles process shortcodes, though there’s a way to make it happen if need be. Wouldn’t you want the title as saved be constructed this way? Or do you really only want the title to appear this way on output, that the saved title is something else? Shortcodes only affect output, not what is saved.

    You can force a title to be something regardless of what a user enters through the ‘wp_insert_attachment_data’ filter. But if your title is dependent on meta values, what would you use if the meta values haven’t been entered yet? I suppose you could throw an error which shows a message like “You must enter style and dish meta fields prior to saving”.

    Thread Starter HI

    (@peterturner849)

    It is not about the title, it’s about Heading 1 (h1). I want to create heading 1 using two or more meta fields, then I wish to use that heading anywhere I can.

    Actually when I am making the heading 1 using ACF, then using Generatepress and Generateblocks elements and its headline block, I am getting a headline 1, but its not perfect, here are the codes I get after publishing…

    <div class="gb-container gb-container-f74e60e6">
    
    <h1 class="gb-headline gb-headline-7f1b92d5 gb-headline-text">This is custom meta field 1</h1>
    
    
    
    <h1 class="gb-headline gb-headline-07e24467 gb-headline-text">this is custom meta field 2</h1>
    
    </div>

    Above, in one div, I got two heading-1 blocks (dynamic meta fields), This div I am using as post title, but the issue here its not in one H1 tag, there are two H2 tags in title, also there is a whitespace between these two H1 blocks.

    I want that, two or more than one meta fields should be used in one H1.

    Moderator bcworkz

    (@bcworkz)

    It doesn’t look like GP elements are working for you. You could try asking through GP’s dedicated support for suggestions on a better approach using their elements.

    An alternative would be to alter the template code that outputs titles to get the ACF data and correctly meld them into one title. The issue here is the same would be applied to all posts using the template. In the case of pages, you could specify which template is used, so one template can use ACF data and the other doesn’t.

    Or you could code the template to use ACF data if it exists, or do a normal title if not.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Post Title with Multiple Custom Fields’ is closed to new replies.