What is the options menu in custom press capable of?

Hi there,

I would like to make use of the "options" located in custom fields section of custompress. I am also confused as to the meaning of the regular expression validation. I have been directed to the usage guide many times now, but have been unable to find any information regarding this topic.

I would like to prepare each of these items to be properly submitted to an MRSS feed.

  • Patrick

    Hey there @Patrick

    I hope you're having a great day!

    The options section for custom fields will display different options depending on the type of custom field you are creating for your post-type(s).

    The "Regular expression validation" box is there so you can enter custom regex code to require a certain format for the data being entered in your custom field.

    Regex (regular expressions) is a somewhat complicated syntax used to validate field input and require that data entered be formatted in a particular manner.

    Here's an explanation of how that could be entered to require data entered in a text box be a vaild URL:
    https://premium.wpmudev.org/forums/topic/regular-expression-validationhow-to-use

    And here's a handy guide to getting started with regex:
    http://www.regular-expressions.info/quickstart.html

    And here's a handy tool to help generate regex for your needs (there are many such online tools):
    http://txt2re.com/index-php.php3

    But validating by regex may not even be necessary for your use-case. What type of fields are you creating, and what are they to be used for?

  • Patrick

    Hi Patrick,

    Great name :slight_smile:

    I am attempting to create a number of custom fields to include with a video url from amazon cloud front. I have included an image to disclose what custom fields I am attempting to use.

    Essentially, I want to have my video editors login to wordpress and fill out all relevant forms of meta data. The most confusing at this point is the video thumbnail.

    The idea is that we want all pertinent meta data (example attached) things like media:id, media:thumbnail to be filled out in the wordpress post. Our hope is that the custom fields will act as media:items and be encoded with the video url. We would like to give our partners access to this media content via an MRSS feed that includes everything you see in the attached MRSS example.

    WPMU dev has saved my hide so many times in the past. Thank you for everything you do :slight_smile: Love the service and community.

  • Ash

    Hello @Patrick

    I hope you are well today.

    By default custom fields are not included in the RSS feed. I have checked your link but it is not working, sent me a 404 error page.

    To add custom fields in rss, you can try to use this plugin: https://wordpress.org/plugins/custom-fields-rss/

    Otherwise, you have to use custom code. Here is a sample code, you need to modify it to fit your needs:

    function add_custom_fields_to_rss() {
        if(get_post_type() == 'my_custom_post_type' && $my_meta_value = get_post_meta(get_the_ID(), 'my_meta_key', true)) {
            ?>
            <my_meta_value><?php echo $my_meta_value ?></my_meta_value>
            <?php
        }
    }
    add_action('rss2_item', 'add_custom_fields_to_rss');

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that, give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    Hope it helps :slight_smile: Please feel free to ask more question if you have.

    Cheers
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.