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

android - net_scheduler holding wakelock -

sql - MySQL : Getting Entries from a many-to-many table -

java - Retrieving data from database using jsp (Hibernate + Spring + Maven) -