Skip to content

Instantly share code, notes, and snippets.

@mrfoxtalbot
Last active May 10, 2021 15:09
Show Gist options
  • Save mrfoxtalbot/dd0b534c32bffce1f70f2bff5eb5420c to your computer and use it in GitHub Desktop.
Save mrfoxtalbot/dd0b534c32bffce1f70f2bff5eb5420c to your computer and use it in GitHub Desktop.
Error in lines 31 & 53
// Warning: Illegal string offset 'alt' in /usr/home/josemorraja.com/web/wp-content/themes/josemorraja-v4/single.php on line 53
// Warning: Illegal string offset 'id' in /usr/home/josemorraja.com/web/wp-content/themes/josemorraja-v4/single.php on line 31
<?php get_template_part('parts/header'); ?>
<div class="container">
<div class="row">
<div class="col-md-12 project-grid">
<?php if(have_posts()): while(have_posts()): the_post();?>
<aside id="post_<?php the_ID()?>" <?php post_class('pull-left menudreta')?>>
<p class="title">
<?php
$title = get_field('menu_title') ? get_field('menu_title') : get_the_title();
echo $title;
?>
</p>
<p><?php the_content()?></p>
<?php get_template_part('parts/share'); ?>
</aside>
<article class="container grid">
<?php
$images = get_field('gallery');
if( $images ):
$count_halves = 0;
foreach($images as $image): ?>
<?php
/* RETRIEVE DATA */
$meta = get_post_meta($image['id']);
$total_width = isset($meta['_total_width']) ? $meta['_total_width'][0] : '';
$horizontal_align = isset($meta['_horizontal_align']) ? $meta['_horizontal_align'][0] : '';
$image_width = isset($meta['_image_width']) ? $meta['_image_width'][0] : '';
$horizontal_margin = isset($meta['_horizontal_margin']) ? $meta['_horizontal_margin'][0] : '';
$vertical_margin = isset($meta['_vertical_margin']) ? $meta['_vertical_margin'][0] : '10';
/* CLASSES */
$class_num_of_cols = $total_width == 'half_page' ? 'col-xs-6 count_half_'.($count_halves % 2) : 'col-xs-12';
$class_image_width = $image_width ? 'width_percent_'.$image_width : '';
$class_hor_align = $horizontal_align ? $horizontal_align : '';
$style_vertical_margin = $vertical_margin ? 'margin-top:'.$vertical_margin.'px;' : '';
$style_horizontal_margin = ($horizontal_align == 'center' || $horizontal_align == '') ? '' : 'margin-'.$horizontal_align.':'.$horizontal_margin.'%;';
/* ROW */
$open_row = ($total_width == 'full_page') || ($total_width == 'half_page' && $count_halves % 2 == 0);
$close_row = ($total_width == 'full_page') || ($total_width == 'half_page' && $count_halves % 2 == 1);
?>
<?php if($open_row): ?> <div class="row"> <?php endif; ?>
<div class="<?php echo $class_num_of_cols;?> col">
<div class="custom <?php echo($class_image_width.' '.$class_hor_align); ?>" style="<?php echo $style_horizontal_margin; ?>">
<img style="<?php echo $style_vertical_margin ?>; " src="<?php echo $image['sizes']['large']; ?>" alt="<?php echo $image['alt']; ?>" class="img-responsive" />
</div>
</div>
<?php if($close_row): ?></div><?php endif; ?>
<?php if($total_width == 'half_page') $count_halves++; ?>
<?php endforeach; ?>
<?php endif;?>
</article>
<?php endwhile; endif; ?>
<div class="share"><?php get_template_part('parts/share'); ?></div>
</div><!-- /#content -->
</div>
</div><!-- /.row -->
</div><!-- /.container -->
<?php get_template_part('parts/footer'); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment