0

Using a plugin and have created a page that offers more fields in a spreadsheet format. To add these extra fields you simply click edit on the row you want to edit....

Now when I am in the plugins template and want create a link to the edit link for that particular post type I keep getting one data for one level down the loop.

In my specific example I have url:

xyz.com/learning/project/test-product

        <?php global $post;

 echo $post->post_name; 
print_r(get_defined_vars());?>

The post name I get is "project". But when dumping my variables I see [post_name] => test-product.

Edit: Later on down the variable list I see [post_name] => project. So obviously I am capturing the later instance. How do I capture the first instance?

1 Answer 1

1

What you want is the get_edit_post_link function.

Usage:

echo '<a href="'.get_edit_post_link( $post_id ).'">edit</a>';

Your use of global $post and the other issue is a separate problem, you should ask a new question and provide more details ( including the code for the template being used )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.