CustomPress Embed Code within PHP

I am attempting embed a custom field into PHP. I know very little about PHP and am wondering if someone can tweak?

  • Eric G.
    • The Crimson Coder

    Here's the code. The middle code is what I need help with.

    <?php $customfield_name = get_post_meta($post->ID, 'ct_Blog_Feed__text_e977', true);
    if ($customfield_name == '') { ?>
    <?php } else { ?>
    
    <?php include_once(ABSPATH.WPINC.'/rss.php');
    wp_rss('. $customfield_name = get_post_meta($post->ID, 'ct_Blog_Feed__text_e977', true) . ', 3); ?>
    
    <?php } ?>
  • Arun Basil Lal
    • New Recruit

    Hey Eric,

    If you are using CustomPress, then you can get the embed codes right from the CustomPress Custom Fields Section. See the screenshot attached.

    You will have to use it like this:

    To show the Custom Field Title:
    <?php echo do_shortcode('[ct id="_ct_datepicker_4f7cb2bec4897" property="title"]'); ?>

    To show the Custom Field Description:
    <?php echo do_shortcode('[ct id="_ct_datepicker_4f7cb2bec4897" property="description"]'); ?>

    to show the Custom Field value (this is the one you would need I think):
    <?php echo do_shortcode('[ct id="_ct_datepicker_4f7cb2bec4897" property="value"]'); ?>

    In general, a Custom Field can be inserted like this, but you already got that:

    < ?php if( get_post_meta($post->ID, "note", true) ): ? >

    here note is the Custom Field .

    I guess you are seeking help with:

    <?php include_once(ABSPATH.WPINC.'/rss.php');
    wp_rss('. $customfield_name = get_post_meta($post->ID, 'ct_Blog_Feed__text_e977', true) . ', 3); ?>

    May I ask, what are you trying to do with this one?

  • Eric G.
    • The Crimson Coder

    @Arun Basil Lal

    Thank you. I understand the embed code. All of them are PHP and I want to insert it in the middle of another set of PHP code. This one:

    Here is the code snippet I am using which works as is:

    <?php require_once(ABSPATH . WPINC . '/rss.php'); wp_widget_rss_output('http://feeds.feedburner.com/Phonearea', array('items' => 5, 'show_author' => 1, 'show_date' => 1));
    ?>

    I want to replace http://feeds.feedburner.com/Phonearea with this Custom Field from CustomPress

    <?php echo do_shortcode('[ct id="ct_Blog_Feed__text_e977" property="title | description | value"]'); ?>

    So that when a feed URL is entered in the Custom Field it would display the latest posts for that Feed address.

  • Arun Basil Lal
    • New Recruit

    Hey Eric,

    I had a quick chat with Ve, and he recommended that we use the get_post_meta function instead of using the shortcodes.

    Here is what it would look like, assuming is the custom field Key (that you can find from the embed code provided by CustomPress )

    <?php
    require_once(ABSPATH . WPINC . '/rss.php');
    wp_widget_rss_output(
    get_post_meta($post->ID, 'ct_Blog_Feed__text_e977', true),
    array(
    'items' => 5,
    'show_author' => 1,
    'show_date' => 1
    )
    );
    ?>

    This should work, Let me know how that goes. :slight_smile:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.