Forums

[resolved] Pass Custom Field Into XML Array? Possible? (3 posts)

  1. arcab4
    Member
    Posted 1 year ago #

    Hi guys and gals,

    so i'm stuck and need some help. I want to use a custom field to pass the value of it into an xml array.

    example:

    here's the custom field snippet i normally use to make it show up on wordpress.

    <?php echo get_post_meta($post->ID, "customfieldA",true); ?>

    and then here's the xml i want it to be passed into.

    $categories[] = array( 'name' => 'DVD Player',
                             'search_options' => array( 'keywords' => 'cheap dvd player' ) );

    So i want to replace "cheap dvd player" with my custom field "customfieldA".

    some other notes:
    i have the XML code on my post template page. So i want to when adding/edting posts, to just insert a keyword into the custom field for that particular post.

    Thanks!

  2. Reuben Gunday
    Member
    Posted 1 year ago #

    So i want to replace "cheap dvd player" with my custom field "customfieldA".

    <?php
     $custom =  get_post_meta($post->ID, "customfieldA",true);
     $categories[] = array( 'name' => 'DVD Player',
          'search_options' => array( 'keywords' => $custom ) );
    ?>
  3. arcab4
    Member
    Posted 1 year ago #

    Hey Reuben,

    Thanks man. that worked perfectly. appreciate your help. saved me hours of searching. :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.