Forums

why this plugin doesn't work ??? (2 posts)

  1. Marcomail
    Member
    Posted 5 years ago #

    function updatelink($id) {

    preg_match('#See the link <a href=(.*)>#', $_POST['content'], $rect);

    $current = get_post_meta($id, 'link');

    if (!isset($current) || (sizeof($current)==0)) {
    add_post_meta($id, 'link', $rect[1]);
    }
    else {
    update_post_meta($id, 'link', $rect[1]);
    }
    }

    add_action('save_post', 'updatersslink');

    i would capture a link when post is saved....but the preg match didn't work good.

    if i use in preg_match "a href=(.*)>" i capture the link with \"...if i use "a href=\"(.*)\">" the script doesn't capture anything...

  2. Marcomail
    Member
    Posted 5 years ago #

    Now it works, how can i return the content of the meta data in the wp loop, i try to use return in the bottom of the function but did'nt return anything....

    function updatersslink() {

    global $post;

    preg_match('#Original link <a href="(.*)">#', $post->post_content, $rect);

    $current = get_post_meta($post->ID, 'rsslink');

    if (!isset($current) || (sizeof($current)==0)) {
    add_post_meta($post->ID, 'rsslink', $rect[1]);
    }
    else {
    update_post_meta($post->ID, 'rsslink', $rect[1]);
    }
    }

    return 'sda79fa7fdfa95taf' ;

    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags