CustomPress Formatting Custom Field Data

Using Custom Fields in CustomPress is there a way to make a default for each field? I would like to make a preset for how the data is formatted. Apparently there is support for pre-formatted fields but not what Im looking for. So I do not have to enter
<a href="mailto:contact@example.com">contact@example.com</a>
for each and every listing? Something like:
<a href="mailto:%field_data%">%field_data%</a>
so I just enter the email for each listing and it automatically shows up as a properly named mailto link?

How do I create this? Thanks!

  • Nomad Freelance
    • Design Lord, Child of Thor

    How do I create this? Should this not be in the support section? I would like some info on what types of formatting CustomPress currently supports and where those template files are etc. Is there a section on the site similar to the codex on wordpress.org where I can read up on all the documentation for the plugins offered on this site and what the functions are etc.

  • Jose
    • Bruno Diaz

    Hi there Nomad,

    Hope you are doing great today.

    Is there a section on the site similar to the codex on wordpress.org where I can read up on all the documentation for the plugins offered on this site and what the functions are etc.

    We have only usage documentation. There is no documentation for the code. You can always ask here in the forum and we will be glad to provide any information.

    With regard to your request, I'm not sure if I understand exactly what you need.
    I assume that you have a custom field for email address, and you want to display a mailto link using that value.

    In that case, you need to use something like this in your template:

    $email_address = do_shortcode('[ct id="ct_Email_text_1db2" property="value"]');
    <a href="mailto:<?php echo $email_address; ?>"><?php echo $email_address; ?></a>

    Of course, you will need to replace the shortcode with the 'Embed code' provided in the custom fields list.

    Please let me know if I understood it correctly and if the snippet works for you.

    Cheers,
    Jose

      • Jose
        • Bruno Diaz

        Hey there @Nomad,

        We already discussed about this in the live chat, but still I would like to follow up here so that the info can be useful for others as well.

        The open_value and close_value attributes are available only for the shortcode custom_fields_block.

        If you need for some reason to add a custom markup to the custom field output, you can extend the shorcode handler using the following hook:

        add_filter('ct_shortcode',  'extend_ct_shortcode', 10, 3);
        function extend_ct_shortcode($result, $atts, $content){
        //Do your stuff here and return the output.
        }

        Hope this helps :slight_smile:

        Cheers,
        Jose

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.