How do you overwrite a core function?
-
Heya,
I need to overwrite this function, can someone tell me what I’m doing wrong because this isn’t working:// THIS FUNCTION OVERWRITES THE ONE THAT ORIGINATES IN WP-INCLUDES/LINK-TEMPLATE.PHP AT LINE 298 TO REMOVE THE FILENAME FROM THE END OF THE "Post URL" BUTTON function modified_get_attachment_link($id = false) { global $post, $wp_rewrite; $link = false; if ( ! $id) $id = (int) $post->ID; $object = get_post($id); if ( $wp_rewrite->using_permalinks() && ($object->post_parent > 0) && ($object->post_parent != $id) ) { $parent = get_post($object->post_parent); if ( 'page' == $parent->post_type ) $parentlink = _get_page_link( $object->post_parent ); // Ignores page_on_front else $parentlink = get_permalink( $object->post_parent ); if ( is_numeric($object->post_name) || false !== strpos(get_option('permalink_structure'), '%category%') ) $name = 'attachment/' . $object->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker else $name = $object->post_name; if ( strpos($parentlink, '?') === false ) $link = user_trailingslashit( trailingslashit($parentlink) ); } if ( ! $link ) $link = home_url( "/?attachment_id=$id" ); return apply_filters('attachment_link', $link, $id); } add_filter('get_attachment_link', 'modified_get_attachment_link', 1, 2);
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘How do you overwrite a core function?’ is closed to new replies.