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.

How to create a dynamic download button with GB & Metabox?

  • Hi

    using Metabox.io I have created a custom field “mediakit” of the type “file_advanced” for the CPT “Talents”.

    I have also created a Content Template for the CPT “Talents”, where I need a button for downloading the file.

    Under the Dynamic Data section of the button blocks panel I have set

    Data Source = Current Post
    Link Source = Post meta
    Post Meta Field = mediakit
    Link Type = Default

    but on the frontend the file won’t be downloaded on posts, where I had uploaded a pdf using this field.

    What irritates me is, that under “”Link Type” I don’t have a “Download” option to chose from, only Default, Email & Telephone.

    What else I need to configure in order to turn the button into a download button for this “mediakit” file?

    Thank you in advance and kind regards,
    Sascha

  • Hi there,

    in GB PRo, you can add attributes in the Advanced Panel of the block settings.

    Select your Button
    In Advanced > Add Attribute and just type: download

  • It does not work.

    I have added “download” to the data-attribute field (not the value field). But instead of the PDF it will download a html-screenshot of the post! I have already tried to change the Button Type from “Link” to “Button”, but then nothing happens.

    Can you please help me dig further? Will provide login-details and link to Element & Post in private note field.

  • The login your provided won’t allow me to view ( or edit ) posts.

  • Oops, pardon, gave wrong role to the temporary-admin …
    Now it has full admin privileges 🙂

    I also added the link to the custom fields to priv notes…

    Warm regards
    Sascha

  • Hi Sascha,

    The return value of the field seems to be an ID.

    For debugging, could you create a Hook Element hooked before_header and displayed to that Post with this code:

    <?php
    
    var_dump(get_post_meta( get_the_ID(), 'mediakit' ));
    
    ?>

    This would output the value of the field so we can debug.

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