Getting page ID inside loop

You can use all template tags inside this file, so to get the ID, just use get_the_ID() (or the_ID() to output it).

get_the_ID() will retrieve the numeric ID of the current post. It has no parameters and returns the ID of the current post.

the_ID() will display the numeric ID of the current post. It also has no parameters.

If you want to access the ID of page which contains your custom loop, then you could do it like this:

Solution 1 (simple, but not very nice way with global variable)

In your page template:

<?php
    global $parent_page_id;
    $parent_page_id = get_the_ID();
    $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
    $args = array( 'post_type' => 'post', 'paged' => $paged );
    $temp = $wp_query;
    $wp_query = null;
    $wp_query = new WP_Query( $args );
    $wp_query->query( $args );
?>

<?php if ( $wp_query->have_posts() ) : ?>
    <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
    <?php get_template_part( 'content', 'custom' ); ?>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>

<?php else : ?>
    <?php get_template_part( 'no-results', 'index' ); ?>
<?php endif; ?>

And in your post-content template:

...
global $parent_page_id; // now you can use parent_page_template variable
...

Solution 2 (nicer way with custom query)

In your page template:

<?php
    $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
    $args = array( 'post_type' => 'post', 'paged' => $paged );
    $my_custom_query = new WP_Query( $args );
?>

<?php if ( $my_custom_query->have_posts() ) : ?>
    <?php while ( $my_custom_query->have_posts() ) : $my_custom_query->the_post(); ?>
    <?php get_template_part( 'content', 'custom' ); ?>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>

<?php else : ?>
    <?php get_template_part( 'no-results', 'index' ); ?>
<?php endif; ?>

And in your post-content template:

...
... $wp_query->queried_object_id; // it will contain object queried in original wp_query
...