Skip to content

Create an Edit link template part #24

@bobbingwide

Description

@bobbingwide

As mentioned in #23 we need the ability to allow an authorsied user easy access to the editor for a displayed post.
This should work for a single post or for any post listed in a query-posts block.

Requirements

  • Ability to display an edit link for the current post
  • Displayed to users who have the authority to edit the post
  • The link text should be (Edit), by default

Proposed solution

In genesis-a2z this was implemented using the [edit] shortcode.
In oik, a similar capability is implemented in the [bw_pages] shortcode as part of the format= parameter.
A value of lower case e causes the [Edit] link to appear for the current post.
It uses the WordPress core function get_edit_post_link()

/**
 * Format the Edit post link (format=e)
 *
 */
function bw_field_function_edit( $post, &$atts, $f ) {
 $link = get_edit_post_link( $post->ID );
 if ( $link ) {
   BW_::alink( "bw_edit", $link, __( "[Edit]", "oik" ) ); 
 }
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions