function wpinventory_get_backlink($anchor = 'Back') { global $post; $args = WPIMCore::get_page_state(); $post_id = !empty($args['post_id']) ? $args['post_id'] : $post->ID; unset($args['post_id']); $url = http_build_query($args); $back = get_permalink($post_id); if ($url) { $back .= stripos($back, '?') !== FALSE ? '&' : '?'; } $back .= $url; $back = '<a href="' . $back . '" class="wpinventory_back">' . $anchor . '</a>'; return $back; }