I have two issues above that are related.
-
php the_title() is outputting the most recent blog post title on the blog list page within my banner (or creating a banner for each blog title on the list page depending on the described circumstance).
-
My advanced custom field used to insert an img url into the background attr of some inline styling is acting the same.
From what I have gathered, both of these issues are caused because the index (blog list) page does not have a $page_id or something to that effect. This make since because it isn’t technically a page I guess.
for the blog title I used:
<?php $blog_title = get_the_title( get_option('page_for_posts', true) ); ?>
<h1><?php echo $blog_title; ?></h1>
This retrieved the title for the page_for_posts
As far as using an advanced custom field (or regular custom field?) on the index page, same issue but different solution:
<?php
$page_id = ( 'page' == get_option( 'show_on_front' ) ? get_option( 'page_for_posts' ) : get_the_ID );
?>
and then
<section class="page_banner inner_banner" style="background: url(<?php the_field('banner_image', $page_id); ?>) center center no-repeat;">
And this worked.
I feel kind of foolish trying to explain something I only slightly understand so if someone could make this more understandable I will choose your answer as correct.