I have a line of code that should be spitting out the phrase "Testing 1"
Instead it's spitting out the letter "h". The exact line of code is in reference to the link tag with in the UL/LI.
My goal is to have the link tag link to individual blogs however using the blog name which is currently referred to as more_blogs_title I am not sure why it is pulling an "h" in I can't find any issues within that line of code at the moment so looking for some help.
Thanks :)
<section>
<?php if ( have_rows( 'blog_layout' ) ): ?>
<?php while ( have_rows( 'blog_layout' ) ) : the_row(); ?>
<?php if ( get_row_layout() == 'blog_structure' ) : ?>
<?php $hero_image = get_sub_field( 'hero_image' ); ?>
<?php if ( $hero_image ) : ?>
<img src="<?php echo esc_url( $hero_image['url'] ); ?>" alt="<?php echo esc_attr( $hero_image['alt'] ); ?>" />
<?php endif; ?>
<div >
<h1><?php the_sub_field( 'blog_title' ); ?></h1>
<?php if ( have_rows( 'blog_body_copy' ) ) : ?>
<?php while ( have_rows( 'blog_body_copy' ) ) : the_row(); ?>
<p><?php the_sub_field( 'blog_body_copy_area' ); ?><p>
<?php endwhile; ?>
</div>
<?php else : ?>
<?php // No rows found ?>
<?php endif; ?>
<div >
<h2><?php the_sub_field( 'more_blogs_header' ); ?></h2>
<?php if ( have_rows( 'more_blogs_links' ) ) : ?>
<?php while ( have_rows( 'more_blogs_links' ) ) : the_row(); ?>
<?php $link_to_blogs = get_sub_field( 'link_to_blogs' ); ?>
<?php if ( $link_to_blogs ) : ?>
<ul>
<li><a href="<?php echo esc_url( $link_to_blogs); ?>"><?php echo esc_html( $link_to_blogs ['more_blogs_title']); ?></a></li>
</ul>
<?php endif; ?>
<?php endwhile; ?>
<?php else : ?>
<?php // No rows found ?>
<?php endif; ?>
<?php endif; ?>
<?php endwhile; ?>
<?php else: ?>
<?php // No layouts found ?>
<?php endif; ?>
</div>
</section>
CodePudding user response:
As I said, I think $link_to_blogs ['more_blogs_title']
is wrong. try
<li><a href="<?php echo esc_url( $link_to_blogs); ?>"><?php echo esc_html( get_sub_field('more_blogs_title')); ?></a></li>
instead of that line.
CodePudding user response:
So I used a plugin called Classic Widgets, and changed some code to get this working.
<a href="<?php echo esc_url( $link_to_blogs['url'] ); ?>" target="<?php echo esc_attr( $link_to_blogs['target'] ); ?>"><?php echo esc_html( $link_to_blogs['title'] ); ?></a>