WordPress.org

Ready to get started?Download WordPress

Forums

Custom Field regex (2 posts)

  1. concon15
    Member
    Posted 2 years ago #

    Hello,

    I use the following code in function.php:

    <?php
    add_filter('the_content', 'embedflash', 0);
    
    function embedflash(){
        $embed = get_the_content('');
    
        $embed = preg_replace('#\[EMB\=(.+)]#i', '<br />blablablablablablabla)
    
    return $embed;
    ?>

    I put here the essential part of the code.
    It allows me to use a different HTML depending on the file published on the site.
    I using this code in post content:
    [EMB=http://www.website.com/upload/file.xxx]

    This code only works when I publish the file in the "content", but doesn't works with custom field. I want to insert this code into a custom field.

    How can I change that please?

    Thank you.

  2. dougvdotcom
    Member
    Posted 2 years ago #

    If you want to capture the value of a custom field, you need to use get_post_custom_values.

    http://codex.wordpress.org/Function_Reference/get_post_custom_values

Topic Closed

This topic has been closed to new replies.

About this Topic