wp editor - Get Post ID with insertedit link

admin2025-01-07  7

Hi I want to get the post ID from the post selected in the insert/edit link button.

I would normally do:

<a 
    data-id="<?php echo $post->ID; ?>" 
    href="<?php the_permalink();?>">
    Sample page link
</a>

But whenever the user adds the links from the tinymce content editor all they get is the permalink, I don't know how to hook in. Can someone please point me in the right direction?

Edit I would like to avoid a plugin. But this is what I am after.. ideally without the bloated [shortcode]

Hi I want to get the post ID from the post selected in the insert/edit link button.

I would normally do:

<a 
    data-id="<?php echo $post->ID; ?>" 
    href="<?php the_permalink();?>">
    Sample page link
</a>

But whenever the user adds the links from the tinymce content editor all they get is the permalink, I don't know how to hook in. Can someone please point me in the right direction?

Edit I would like to avoid a plugin. But this is what I am after.. ideally without the bloated [shortcode]

Share Improve this question edited Feb 11, 2017 at 8:50 uriah asked Feb 11, 2017 at 8:44 uriahuriah 1213 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Not an exact answer to your question (hooking into the insert/edit link functionality), but possibly an alternate method that can achieve the same goal (inputting a permalink, outputting a Post ID):

https://codex.wordpress.org/Function_Reference/url_to_postid

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736260736a686.html

最新回复(0)