SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Wordpress Custom Fields & JS help

    Hi, I am trying to set a code in my functions.php that auto adds a custom field on a new post. Now, I have that working. However, the value I want it to insert is from a javascript file. The js file's value will change each day. All I can manage to get the custom field to do is add the code for the js file, therefore, what is displayed in posts will change every day. I want it to get the current value on the day of posting and to insert that value to the custom field.

    Eg. if today the value of the file was "3" I want the number 3 to be inserted as a custom field. However, if the js code is just inserted, the next day, the post will display 4. I want it to insert the constant value the file has that day and it to stay like that.

    Here is the code I have at the moment :

    add_action('publish_page', 'add_custom_field_automatically');
    add_action('publish_post', 'add_custom_field_automatically');
    function add_custom_field_automatically($post_ID) {
    global $wpdb;
    if(!wp_is_post_revision($post_ID)) {
    add_post_meta($post_ID, 'day', '<script type="text/javascript">eval(http://bbuk4network.com/wp-content/themes/cbbcosmos/day.js)</script>">
    </script>', $meta_value, true);
    }
    }

  2. #2
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any wordpress wizards have any ideas ? I would really appreciate if anyone could try help

  3. #3
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can anyone please help ? I would really appreciate it

  4. #4
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have tried some things but I still cannot get the script to execute before adding to the custom fields... eh, anyone else thought of any ideas ?

  5. #5
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Someone suggested something on another site,but, I still cannot get this working and it is quite important that I find a fix. I would REALLY appreciate any help

  6. #6
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It really is vital I find a solution for this... please, can somebody help or even reply ????


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •