我知道怎么用get_the_permalink() 功能:
/* Protect Member Only Posts*/
function post_filter( $content ) {
    $categories = array(
        \'coding\',
        \'python\',
        \'linux-tutorials\',
        \'swift\',
        \'premium\',
    );
    if ( in_category( $categories ) ) {
        if ( is_user_logged_in() ) {
            return $content;
        } else {
            $link = get_the_permalink();
            $link = str_replace(\':\', \'%3A\', $link);
            $link = str_replace(\'/\', \'%2F\', $link);
            $content = "<p>Sorry, this post is only available to members. <a href=\\"gateblogs.com/login?redirect_to=$link\\">Sign in/Register</a></p>";
            return $content;
        }
    } else {
         return $content;
    }
}
add_filter( \'the_content\', \'post_filter\' );
 请注意
str_replace 因为我必须更改链接才能使插件工作。