WordPress.org

Ready to get started?Download WordPress

Forums

Press This, pass url as custom field (4 posts)

  1. artfulalibi
    Member
    Posted 6 years ago #

    Hello,

    I was wondering if there is a way to pass the automatic url grabbed by the Press This feature automatically, and pass it into a custom field value?

    I saw that someone else also posted for this, but with no response.

    Thanks!

  2. noel
    Member
    Posted 5 years ago #

    Which url would you be referring to?

  3. ericlee
    Member
    Posted 5 years ago #

    I guess the URL is referring to the URL Address that was been blog. If I am not wrong, it is listed as $url in the press_it.php.

    I am looking at possible solution as well.

    Tried various method but does not work.

    Insert the post meta in the press_it function

    // insert the post with nothing in it, to get an ID
    	$post_ID = wp_insert_post($quick, true);
            add_post_meta($post_ID, 'elink', $url);

    and also try to insert a custom field form at the bottom of the page. It show the form all right but it is not able to update/insert the custom field.

    <?php
     $metadata = has_meta($post->ID);
     list_meta($metadata);
     meta_form();
    ?>

    I am not a programmer, but I am willing to try. However, I am stuck for a few days. Hope some kind soul would shed some light...

    Thanks in advance...

  4. ericlee
    Member
    Posted 5 years ago #

    Ok, manage to get it right after several try.
    Here it goes...

    Add a input tag at this section.
    So that the url will be shown. Else, you can customise the url if you want.

    <div class="editor-container">
    				<textarea name="content" id="content" style="width:100%;" class="mceEditor" rows="15">
    					<?php if ($selection) echo wp_richedit_pre(htmlspecialchars_decode($selection)); ?>
    					<?php // if ($url) { echo '<p>'; if($selection) _e('via '); echo "<a href='$url'>$title</a>."; echo '</p>'; } ?>
    				</textarea>
                                    <input name="elink" type="text"  id="elink" class="mceEditor" style="width:100%;" value="<?php echo $url; ?>"/>
    
    			</div>

    Now go to the top section and insert the $elink stuff.

    $quick['post_title'] = $_REQUEST['title'];
    	$quick['post_content'] = '';
            $elink = $_REQUEST['elink'];

    and follow by this, adding the post meta

    $quick['ID'] = $post_ID;
    		wp_update_post($quick);
                    add_post_meta($post_ID, 'elink', $elink, false);

    Doesn't look clean, but it serve my purpose all right.

    Cheers

Topic Closed

This topic has been closed to new replies.

About this Topic