The post.php screen lists posts vertically in the admin area [and other post types]. Each item's post_title is a hyperlink, directly above some inline choices. Both the title link, and the "Edit" inline selection, redundantly go to the same destination, namely:


enter image description here

I want to filter the post_title URL href using PHP. Specifically, I want to set a custom destination to the URL, based on metadata stored in the post. i.e post_ID:123 has post meta data:

{'custom_URL' : 'http:somesite.com'}

In post.php, how can I change the post_title hyperlink href destination URL, to a custom destination - preferably with PHP?

I'll need to somehow intercept the main query loop within post.php, because I need to do a metadata query for each of the displayed items, based on their postID. Which could be 1-200 things, generally. I could use JS to fetch the post IDs, and then do an API call(s) to the server from the browser, but I'd rather filter it from PHP before it's emitted.

1 Answer 1


The post title and inline "Edit" links in the posts list table at wp-admin/edit.php uses get_edit_post_link() which applies a filter hook also named get_edit_post_link, so if (I correctly understood that) you want to modify those links (URL), you can use that filter. E.g.

// Note: The callback will run anywhere, not just at wp-admin/edit.php
add_filter( 'get_edit_post_link', 'my_filter_edit_post_link', 10, 2 );
function my_filter_edit_post_link( $link, $post_id ) {
    $url = get_post_meta( $post_id, 'custom_URL', true );

    // it's all up to you on what params to add to the custom URL
    return $url ? add_query_arg( 'post', $post_id, $url ) : $link;

Your Answer

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

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