Show image description/caption in WordPress - php

When I try to get the caption or description from a image in wordpress it's not working. I can't find a real answer. I tried so many things but I don't know where i have to put some of the code. I read that I had to put this in functions.php:
function wp_get_attachment( $attachment_id ) {
$attachment = get_post( $attachment_id );
return array(
'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
'caption' => $attachment->post_excerpt,
'description' => $attachment->post_content,
'href' => get_permalink( $attachment->ID ),
'src' => $attachment->guid,
'title' => $attachment->post_title
);
}
$attachment_meta = wp_get_attachment(your_attachment_id);
and this in my loop:
<?php echo $attachment_meta['caption']; ?>
Like this:
<section>
<div class="container">
<div class="row">
<?php
if( class_exists('Dynamic_Featured_Image') ):
global $dynamic_featured_image;
global $post;
$featured_images = $dynamic_featured_image->get_featured_images( $post->ID );
if ( $featured_images ):
?>
<?php foreach( $featured_images as $images ): ?>
<div class="col-md-4 col-sm-4 col-xs-12">
<img src="<?php echo $images['full'] ?>" alt="" class="img-responsive">
<?php echo $attachment_meta['caption']; ?>
</div>
<?php endforeach; ?>
<?php
endif;
endif;
?>
</div>
</div>
</section>
What am I doing wrong?

You must call wp_get_attachment() function inside your loop like this:
<?php foreach( $featured_images as $images ): ?>
<div class="col-md-4 col-sm-4 col-xs-12">
<img src="<?php echo $images['full'] ?>" alt="" class="img-responsive">
$attachment_meta = wp_get_attachment($images['attachment_id']);
<?php echo $attachment_meta['caption']; ?>
</div>
<?php endforeach; ?>

Related

Critical error on single product page woo commerce

My website started showing this strange error recently which I have been unable to resolve. When I try to view a product, it returns a critical error.
I’ve done some troubleshooting and I realized the theme is the culprit. I have also checked the error log and I saw that this specific line of code is causing the error:
Uncaught Error: Call to a member function is_in_stock() on string in /home/u306409103/domains/apdbrestore.com/public_html/wp-content/themes/custom-theme/woocommerce/single-product.php:45 Stack trace: #0
When you check that line, it says:
<?php if( !$product->is_in_stock() ) : ?>
<div class="outofstock">
<img src="<?php echo imgfolder('out-of-stock.png'); ?>" alt="Out of Stock">
</div>
<?php endif; ?>
To be specific the error is pointing towards the first line:
<?php if( !$product->is_in_stock() ) : ?>
I know the problem is coming from here but don’t know what next to do. What statement can I use here to do away with this error?
Thanks
Full code
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
get_header( 'shop' ); ?>
<?php
/**
* woocommerce_before_main_content hook.
*
* #hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
* #hooked woocommerce_breadcrumb - 20
*/
do_action( 'woocommerce_before_main_content' );
?>
<?php
if( has_post_thumbnail() ) :
$img = get_the_post_thumbnail_url();
else :
$img = placeholder();
endif;
?>
<div class="product-single">
<div class="container">
<div class="row">
<div class="col-md-7">
<div class="product-single-left product-contain">
<?php if( !$product->is_in_stock() ) : ?>
<div class="outofstock">
<img src="<?php echo imgfolder('out-of-stock.png'); ?>" alt="Out of Stock">
</div>
<?php endif; ?>
<div class="product-single-holder">
<div class="product-single-gallery">
<div class="product-single-image active" data-img="<?php echo $img; ?>" style="background-image: url(<?php echo $img; ?>);"></div>
<?php global $product;
$attachment_ids = $product->get_gallery_attachment_ids();
foreach( $attachment_ids as $attachment_id ) { ?>
<div class="product-single-image" data-img="<?php echo wp_get_attachment_url( $attachment_id ); ?>" style="background-image: url(<?php echo $image_link = wp_get_attachment_url( $attachment_id ); ?>);"></div>
<?php } ?>
</div>
</div>
<div class="product-single-featured">
<img src="<?php echo $img; ?>" alt="<?php echo get_the_title(); ?>">
</div>
</div>
</div>
<div class="col-md-5">
<div class="product-single-content">
<h3><?php echo get_the_title(); ?></h3>
<div class="product-single-price">
<div class="home-sale-price">
<?php if( $product->get_sale_price() ) : ?>
<div class="home-sale-less">
Listed Price - <span>P <?php echo wc_price( wc_get_price_to_display( $product, array( 'price' => $product->get_sale_price() ) ) ); ?> </span>
</div>
<div class="home-sale-orig">
<?php echo 'P '.wc_price( wc_get_price_to_display( $product, array( 'price' => $product->get_regular_price() ) ) ); ?>
</div>
<?php else : ?>
<div class="home-sale-less">Listed Price - <span>P <?php echo wc_price( wc_get_price_to_display( $product, array( 'price' => $product->get_regular_price() ) ) ); ?> </span></div>
<?php endif; ?>
</div>
<?php if(get_field('terms')): ?>
<div class="home-sale-term">Terms - <span>P <?php echo get_field('terms'); ?></span></div>
<?php endif; ?>
<?php if(get_field('dp_and_pay')): ?>
<div class="product-single-term"><?php echo get_field('dp_and_pay'); ?></div>
<?php endif; ?>
</div>
<div class="product-single-desc">
<?php echo apply_filters( 'the_content', $product->get_short_description() ); ?>
</div>
<i class="fas fa-plus-square"></i>Add to Cart
</div>
<?php while ( have_posts() ) : the_post(); ?>
<?php //wc_get_template_part( 'content', 'single-product' ); ?>
<?php endwhile; // end of the loop. ?>
</div>
</div>
</div>
<div class="home-sale home-new">
<div class="container">
<div class="row justify-content-center">
<div class="col-md-10">
<div class="header-excerpt">
<?php $salehead = get_field('new_arrivals_content',8); ?>
<h3>Recommmended Items</h3>
<div class="header-excerpt-text"><?php echo $salehead['content']; ?></div>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="home-sale-slider">
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => -1,
'order_by' => 'date',
'order' => 'DESC'
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post();
if( has_post_thumbnail() ) :
$img = get_the_post_thumbnail_url();
else :
$img = placeholder();
endif;
$product = wc_get_product(get_the_ID());
?>
<div class="home-sale-holder product-contain">
<?php if( !$product->is_in_stock() ) : ?>
<div class="outofstock">
<img src="<?php echo imgfolder('out-of-stock.png'); ?>" alt="Out of Stock">
</div>
<?php endif; ?>
<div class="home-sale-top">
<img src="<?php echo $img; ?>" alt="<?php echo get_the_title(); ?>">
<i class="fas fa-plus-square"></i>Add to cart
</div>
<div class="home-sale-bottom">
<a href="<?php echo get_permalink(); ?>">
<h5><?php echo get_the_title(); ?></h5>
<div class="home-sale-price">
<?php if( $product->get_sale_price() ) : ?>
<div class="home-sale-less">
Cash - <span>P <?php echo wc_price( wc_get_price_to_display( $product, array( 'price' => $product->get_sale_price() ) ) ); ?> </span>
</div>
<div class="home-sale-orig">
<?php echo 'P '.wc_price( wc_get_price_to_display( $product, array( 'price' => $product->get_regular_price() ) ) ); ?>
</div>
<?php else : ?>
<div class="home-sale-less">Cash - <span>P <?php echo wc_price( wc_get_price_to_display( $product, array( 'price' => $product->get_regular_price() ) ) ); ?> </span></div>
<?php endif; ?>
</div>
<?php if(get_field('terms')): ?>
<div class="home-sale-term">Terms - <span>P <?php echo get_field('terms'); ?></span></div>
<?php endif; ?>
</a>
</div>
</div>
<?php endwhile;
} else {
echo __( 'No products found' );
}
wp_reset_postdata();
?>
</div>
</div>
</div>
</div>
View All Products
</div>
</div>
<?php
/**
* woocommerce_after_main_content hook.
*
* #hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
*/
do_action( 'woocommerce_after_main_content' );
?>
<?php
/**
* woocommerce_sidebar hook.
*
* #hooked woocommerce_get_sidebar - 10
*/
do_action( 'woocommercve_sidebar' );
?>
<?php get_footer( 'shop' );
/* Omit closing PHP tag at the end of PHP files to avoid "headers already sent" issues. */
Finally got the solution to this problem and in case anyone stumbles across this, all I had to do was to update how to get the reference post ID because the existing one is deprecated already.
<?php global $product;
$product = wc_get_product( $post->ID );
$stock_quantity = get_post_meta($post->ID, '_stock', true);
//var_dump($product->get_stock_status());
?>
<?php if ($product->get_stock_status() != 'instock') : ?>
<div class="outofstock">
<img src="<?php echo imgfolder('out-of-stock.png'); ?>" alt="Out of Stock">
</div>
<?php endif; ?>
Make sure that the $product is not a string or a boolean before checking for stock.
<?php if( is_object($product) && !$product->is_in_stock() ) : ?>
Or, you completly stop processing the template by bailing out at the top if no product was returned like this:
if (!is_object($product)) {
return;
}
Try to put this code, I updated your code a bit.
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
get_header( 'shop' );
global $product;
?>
<?php
/**
* woocommerce_before_main_content hook.
*
* #hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
* #hooked woocommerce_breadcrumb - 20
*/
do_action( 'woocommerce_before_main_content' );
?>
<?php
if( has_post_thumbnail() ) :
$img = get_the_post_thumbnail_url();
else :
$img = placeholder();
endif;
?>
<div class="product-single">
<div class="container">
<div class="row">
<div class="col-md-7">
<div class="product-single-left product-contain">
<?php if( !$product->is_in_stock() ) : ?>
<div class="outofstock">
<img src="<?php echo imgfolder('out-of-stock.png'); ?>" alt="Out of Stock">
</div>
<?php endif; ?>
<div class="product-single-holder">
<div class="product-single-gallery">
<div class="product-single-image active" data-img="<?php echo $img; ?>" style="background-image: url(<?php echo $img; ?>);"></div>
<?php
$attachment_ids = $product->get_gallery_attachment_ids();
foreach( $attachment_ids as $attachment_id ) { ?>
<div class="product-single-image" data-img="<?php echo wp_get_attachment_url( $attachment_id ); ?>" style="background-image: url(<?php echo $image_link = wp_get_attachment_url( $attachment_id ); ?>);"></div>
<?php } ?>
</div>
</div>
<div class="product-single-featured">
<img src="<?php echo $img; ?>" alt="<?php echo get_the_title(); ?>">
</div>
</div>
</div>
<div class="col-md-5">
<div class="product-single-content">
<h3><?php echo get_the_title(); ?></h3>
<div class="product-single-price">
<div class="home-sale-price">
<?php if( $product->get_sale_price() ) : ?>
<div class="home-sale-less">
Listed Price - <span>P <?php echo wc_price( wc_get_price_to_display( $product, array( 'price' => $product->get_sale_price() ) ) ); ?> </span>
</div>
<div class="home-sale-orig">
<?php echo 'P '.wc_price( wc_get_price_to_display( $product, array( 'price' => $product->get_regular_price() ) ) ); ?>
</div>
<?php else : ?>
<div class="home-sale-less">Listed Price - <span>P <?php echo wc_price( wc_get_price_to_display( $product, array( 'price' => $product->get_regular_price() ) ) ); ?> </span></div>
<?php endif; ?>
</div>
<?php if(get_field('terms')): ?>
<div class="home-sale-term">Terms - <span>P <?php echo get_field('terms'); ?></span></div>
<?php endif; ?>
<?php if(get_field('dp_and_pay')): ?>
<div class="product-single-term"><?php echo get_field('dp_and_pay'); ?></div>
<?php endif; ?>
</div>
<div class="product-single-desc">
<?php echo apply_filters( 'the_content', $product->get_short_description() ); ?>
</div>
<i class="fas fa-plus-square"></i>Add to Cart
</div>
<?php while ( have_posts() ) : the_post(); ?>
<?php //wc_get_template_part( 'content', 'single-product' ); ?>
<?php endwhile; // end of the loop. ?>
</div>
</div>
</div>
<div class="home-sale home-new">
<div class="container">
<div class="row justify-content-center">
<div class="col-md-10">
<div class="header-excerpt">
<?php $salehead = get_field('new_arrivals_content',8); ?>
<h3>Recommmended Items</h3>
<div class="header-excerpt-text"><?php echo $salehead['content']; ?></div>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="home-sale-slider">
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => -1,
'order_by' => 'date',
'order' => 'DESC'
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post();
if( has_post_thumbnail() ) :
$img = get_the_post_thumbnail_url();
else :
$img = placeholder();
endif;
$new_product = wc_get_product(get_the_ID());
?>
<div class="home-sale-holder product-contain">
<?php if( !$new_product->is_in_stock() ) : ?>
<div class="outofstock">
<img src="<?php echo imgfolder('out-of-stock.png'); ?>" alt="Out of Stock">
</div>
<?php endif; ?>
<div class="home-sale-top">
<img src="<?php echo $img; ?>" alt="<?php echo get_the_title(); ?>">
<i class="fas fa-plus-square"></i>Add to cart
</div>
<div class="home-sale-bottom">
<a href="<?php echo get_permalink(); ?>">
<h5><?php echo get_the_title(); ?></h5>
<div class="home-sale-price">
<?php if( $new_product->get_sale_price() ) : ?>
<div class="home-sale-less">
Cash - <span>P <?php echo wc_price( wc_get_price_to_display( $new_product, array( 'price' => $new_product->get_sale_price() ) ) ); ?> </span>
</div>
<div class="home-sale-orig">
<?php echo 'P '.wc_price( wc_get_price_to_display( $new_product, array( 'price' => $new_product->get_regular_price() ) ) ); ?>
</div>
<?php else : ?>
<div class="home-sale-less">Cash - <span>P <?php echo wc_price( wc_get_price_to_display( $new_product, array( 'price' => $new_product->get_regular_price() ) ) ); ?> </span></div>
<?php endif; ?>
</div>
<?php if(get_field('terms')): ?>
<div class="home-sale-term">Terms - <span>P <?php echo get_field('terms'); ?></span></div>
<?php endif; ?>
</a>
</div>
</div>
<?php endwhile;
} else {
echo __( 'No products found' );
}
wp_reset_postdata();
?>
</div>
</div>
</div>
</div>
View All Products
</div>
</div>
<?php
/**
* woocommerce_after_main_content hook.
*
* #hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
*/
do_action( 'woocommerce_after_main_content' );
?>
<?php
/**
* woocommerce_sidebar hook.
*
* #hooked woocommerce_get_sidebar - 10
*/
do_action( 'woocommercve_sidebar' );
?>
<?php get_footer( 'shop' );

Slick Slider Carousel with Recent post loop not working

I am trying to implement a recent posts carousel using Slick Slider and ACF.
I have found a great tutorial and followed the instructions here:
https://imranhsayed.medium.com/slick-slider-wordpress-without-plugin-slick-carousel-ef2394c737ef
and after MUCH trial and error I can get it to work as expected using some basic test content like this:
<div class="posts-carousel">
<div>test</div>
<div>test</div>
<div>test</div>
</div>
But when I try and implement the code for the recent posts loop, I just get a white screen. I'm not great at php but I have tried to work out the issue and just I can't see it.
Another code example that is given works perfectly when copy and pasted:
<div class="posts-carousel px-5">
<!--Slide One-->
<div class="card">
<img width="350" height="233" src="https://via.placeholder.com/150" class="w-100" alt="alt-text">
<div class="card-body">
<h3 class="card-title">Your Post heading</h3>
<p>Your Post Excerpt</p>
View More
</div>
</div>
<!--Slide Two-->
<div class="card">
<img width="350" height="233" src="https://via.placeholder.com/150" class="w-100" alt="alt-text">
<div class="card-body">
<h3 class="card-title">Your Post heading</h3>
<p>Your Post Excerpt</p>
View More
</div>
</div>
</div>
But the code example for including a post loop does not
<?php
/**
* Posts Carousel
*
* #package aquila
*/
$args = [
'posts_per_page' => 5,
'post_type' => 'post',
'update_post_meta_cache' => false,
'update_post_term_cache' => false,
];
$post_query = new \WP_Query( $args );
?>
<div class="posts-carousel px-5">
<?php
if ( $post_query->have_posts() ) :
while ( $post_query->have_posts() ) :
$post_query->the_post();
?>
<div class="card">
<?php
if ( has_post_thumbnail() ) {
the_post_custom_thumbnail(
get_the_ID(),
'featured-thumbnail',
[
'sizes' => '(max-width: 350px) 350px, 233px',
'class' => 'w-100',
]
);
} else {
?>
<img src="https://via.placeholder.com/510x340" class="w-100" alt="Card image cap">
<?php
}
?>
<div class="card-body">
<?php the_title( '<h3 class="card-title">', '</h3>' ); ?>
<?php aquila_the_excerpt(); ?>
<a href="<?php echo esc_url( get_the_permalink() ); ?>" class="btn btn-primary">
<?php esc_html_e( 'View More', 'aquila' ); ?>
</a>
</div>
</div>
<?php
endwhile;
endif;
wp_reset_postdata();
?>
</div>
I tried editing or removing the references to 'aquila' which I think is the theme the post writer it using but it did not work
I currently have this:
<?php
$args = [
'posts_per_page' => 2,
'post_type' => 'post',
];
$post_query = new WP_Query( $args );
?>
<div class="posts-carousel px-5">
<?php
if ( $post_query->have_posts() ) :
while ( $post_query->have_posts() ) :
$post_query->the_post();
?>
<div class="card">
<?php
if ( has_post_thumbnail() ) {
the_post_custom_thumbnail(
get_the_ID(),
'featured-thumbnail',
[
'sizes' => '(max-width: 350px) 350px, 233px',
'class' => 'w-100',
]
);
} else {
?>
<img src="https://via.placeholder.com/510x340" class="w-100" alt="Card image cap">
<?php
}
?>
<div class="card-body">
<?php the_title( '<h3 class="card-title">', '</h3>' ); ?>
</div>
</div>
<?php
endwhile;
endif;
wp_reset_postdata();
?>
</div>
I have actually found a plugin that can do it for me, but I feel like I am so close to getting it working, i just can't work it out.
Any help would be great
I have the same problem. You can try change the name of thumbnail function :
<?php
if ( $post_query->have_posts() ) :
while ( $post_query->have_posts() ) :
$post_query->the_post();
?>
<div>
<div class="card">
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail(
get_the_ID(),
'featured-thumbnail',
[
'sizes' => '(max-width: 350px) 350px, 233px',
'class' => 'w-100',
]
);
} else {
?>
<img src="https://via.placeholder.com/510x340" class="w-100" alt="Card image cap">
<?php
}
?>
<div class="card-body">
<?php the_title( '<h3 class="card-title">', '</h3>' ); ?>
<?php the_excerpt(); ?>
<a href="<?php echo esc_url( get_the_permalink() ); ?>" class="btn btn-primary">
<?php esc_html_e( 'View More', 'aquila' ); ?>
</a>
</div>
</div>
</div>
<?php
endwhile;
endif;
wp_reset_postdata();

PHP does not output in columns

I am trying to output my text in col-sm-4 but only the first item is going into the col-sm-4
The rest is out of order
Here is my code:
<div class="col-sm-6">
<?php
// Team ophalen
$team_posts = get_posts( array(
'post_type' => 'team',
'posts_per_page' => -1,
'orderby' => 'title',
) );
if ( $team_posts ):
?>
<div class="col-sm-4">
<?php
foreach ( $team_posts as $post ):
setup_postdata($post);
// Foto URL
$thumb_src = null;
if ( has_post_thumbnail($post->ID) ) {
$src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'team-thumb' );
$thumb_src = $src[0];
}
?>
<div class="card" <?php if ( $thumb_src ): ?>style="background-image: url('<?php echo $thumb_src; ?>');"<?php endif; ?>>
<div class="card-name">
<span class="text-center underline"><?php the_title(); ?></span>
</div>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
As #castis said, your col-sm-4 is not a part of the loop.
This should work.
<?php
$team_posts = get_posts(array(
'post_type' => 'team',
'post_per_page' => -1,
'orderby' => 'title',
));
if($team_posts);
?>
<?php
foreach($team_posts as $post):
setup_pustdata($_POST);
$thumb_src = null;
if(has_post_thumbnail($post->ID)) {
$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'team-thumb');
$thumb_src = $src[0];
}
?>
<div class="col-sm-4">
<div class="card" <?php if ($thumb_src): ?>style="background-image: url('<?php echo $thumb_src; ?>');"<?php endif; ?>>
<div class="card-name">
<span class="text-center underline"><?php the_title(); ?></span>
</div>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>

Wordpress shortcode with a loop

I'm fairly new with using WP shortcodes, and I've run into a problem. I have tried to make a shortcode, that shows 6 of my blog posts through a loop, but it doesn't work. When it loads, it just smashes the page. The loop code works in practice, just not with the shortcode.
The code
function myshort() { ?>
<?php
$args = array( 'post_type' => 'cases', 'posts_per_page' => 6 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
?>
<div class="col-sm-6 wow fadeInUp" data-wow-delay="0.1s">
<a class="content" href="<?php echo get_permalink( $post->ID ); ?>">
<div class="image">
<?php the_post_thumbnail(); ?>
</div>
<div class="text">
<span class="date"><?php echo rwmb_meta( 'rw_stitle' ); ?></span>
<h3><?php the_title(); ?></h3>
<p><?php echo rwmb_meta( 'rw_sdesc' ); ?></p>
</div>
</a>
</div>
<?php endwhile;
}
add_shortcode('doitman', 'myshort');
So, my question is, how do I write this the right way?
The result should be returned as a value,
you could try something like this :
function myshort() {
ob_start(); ?>
<?php
$args = array( 'post_type' => 'cases', 'posts_per_page' => 6 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
?>
<div class="col-sm-6 wow fadeInUp" data-wow-delay="0.1s">
<a class="content" href="<?php echo get_permalink( $post->ID ); ?>">
<div class="image">
<?php the_post_thumbnail(); ?>
</div>
<div class="text">
<span class="date"><?php echo rwmb_meta( 'rw_stitle' ); ?></span>
<h3><?php the_title(); ?></h3>
<p><?php echo rwmb_meta( 'rw_sdesc' ); ?></p>
</div>
</a>
</div>
<?php endwhile;
return ob_get_clean();
}
add_shortcode('doitman', 'myshort');

CPT output on page breaks other fields

Not sure what i have done wrong here but i noticed that everything dissapears below my code.
If i take fields and put them in top of template then everything works fine.
Code
<?php
$blacklabelpost = array( 'post_type' => 'black-label', );
$loop = new WP_Query( $blacklabelpost );
?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php
$images = get_field('photos_of_product'); // get gallery
$image = $images[0]; // get first image in the gallery [1] for second, [2] for third, and so on.
if( $image ) : // only show the image if it exists ?>
<div class="col-sm-3 col-md-4 col-lg-3 product-col">
<a href="<?php the_permalink() ?>">
<img src="<?php echo $image['url']; ?>" class="img-responsive"/>
</a>
<div class="row text-center">
<div class="col-xs-12">
<h3 class="UC sTitle"><?php the_title()?></h3>
<div class="border-line center"></div>
<div class="subtitle about_product_short UC"><?php the_field('about_product_short'); ?></div>
</div>
<div class="col-xs-12">
Läs mer
</div>
</div>
</div>
<?php endif; ?>
<?php endwhile; ?>
Below i just have couple of if get field.
Example
<?php if( get_field('full_width_photo_footer') ): ?>
<div class="F-W sida archive">
<?php
$image = get_field('full_width_photo_footer');
if( !empty($image) ): ?>
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" class="img-responsive footer-fullwidth-img"/>
<?php endif; ?>
</div>
<?php endif; ?>
As soon as i delete this 'full_width_photo_footer' starts to work again:
<?php
$mypost = array( 'post_type' => 'white-label', );
$loop = new WP_Query( $mypost );
?>
What am i doing wrong ?

Categories