php - Wordpress as an endpoint -


so, i'm building , need use wordpress endpoint.

i’ve post url http://example.com/sample-post. i’ve added rewrite endpoint “edit”. url becomes http://example.com/sample-post/edit. whats right way print url? should like:

<?php echo get_permalink() . '/edit'; ?> 

or there prefered way?

yes, preferred way. however, recommend writing function in functions.php additional checks before printing link:

function get_custom_edit_link() {     // check if we're on post page     return is_single() ? get_permalink() . '/edit' : ''; } 

and in template, call with:

echo get_custom_edit_link(); 

however, if you're using link head edit.php, may want consider using the get_edit_link() method of wp_posts_list_table class.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -