How can I restrict access to specific parts of a page, not just the page itself?

If you’re wanting to limit by a capability (built in or custom) you can use current_user_can() and pass the appropriate capability.

if( current_user_can('manage_options') ) {
    echo "Hi there user who can manage options';
}

Keep in mind that the post or page content is one chunk and you would need to do something much more custom to hide certain paragraphs etc.

In that case you may need a shortcode to wrap the content you want to hide – actually that is a great idea for a plugin that most likely already exists 🙂

EDIT:

I wrote this up quickly. Needs a bit of testing. The cap is optional and will default to having to be logged in to see the content if not set.

class Hide_Content {

    function render_shortcode( $atts, $content = "" ) {
        //get the atts passed to the shortcode
        $atts = shortcode_atts( array(
            'cap' => false,
        ), $atts );

        //we need to be logged in either way
        if( is_user_logged_in() ) {

            // there is a cap set and the user can do it - we're good
            if( $atts['cap'] && current_user_can( $atts['cap']) ) {
                return "content {$atts['cap']} = $content";
            }else{

                //if there is no cap set - we'll just show it to logged in users
                return 'Logged in only :: ' . $content ;
            }
        }
    }
}
add_shortcode( 'hide_content', array( 'Hide_Content', 'render_shortcode' ) );

//useage
[hide_content cap="manage_options"]This is hidden from non-logged in and users who can't manage options[/hide_content]