Function with grid of ACF fields
-
Hello,
Sorry if this question doesn’t belong here, but I don’t know where to put it elsewhere. And sorry if this has been solved already, i’ve done extensive searching and testing but can’t figure it out by myself.
What I want: I want to let my client fill in custom fields for title, image and link. Then I want a custom function [ivl_film] to generate a grid of images with mouseover titles linked to a certain page.
The HTML and CSS part I can do, but it’s the php part where my knowledge is too limited.
I’ve created a php function in functions.php but don’t know how to make the grid work then. Can anyone please help me? Regarding I’m an absolute beginner in php ??What I now have (but doesn’t work, I don’t understand why..):
function ivl_film_func() { $posts = get_posts(array( 'posts_per_page' => -1, 'post_type' => 'post' )); if( $posts ): ?> <ul> <?php foreach( $posts as $post ): setup_postdata( $post ) ?> <li> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </li> <?php endforeach; ?> </ul> <?php wp_reset_postdata(); ?> <?php } add_shortcode( 'ivl_film', 'ivl_film_func' );
Many thanks in advance!!
- The topic ‘Function with grid of ACF fields’ is closed to new replies.