CTA Example: Featured Content
Displaying a featured CTA based on the current item within the loop
In this example:
Ajax Load More will use the Call to Actions add-on to inject a custom CTA template before the 2nd post in each query.
-
Ajax Load More Post Example
Cras justo odio, dapibus ac facilisis in, egestas eget...
-
REST API
Enable compatibility between Ajax Load More and the WordPress REST API
Learn More
-
Donec ullam corper nulla metus auctor frinel
Sociis natoque penatibus et magnis dis parturient montes, nascetur...
-
Lorem Ipsum Maec diam eget risus varius blandit
Donec ullamcorper nulla non metus auctor fringilla. Maecenas faucibus...
-
Pellentesque ornare sem lacinia quam venenatis vestibulum
Maecenas faucibus mollis interdum. Morbi leo risus, porta ac...
-
Diam eget risus varius blandit sit amet
Maecenas faucibus mollis interdum. Morbi leo risus, porta ac...
The following shortcode was used to create the CTA Example: Featured Content example.
[ajax_load_more cta="true" cta_position="before:2" cta_theme_repeater="custom-cta.php" post_type="post" posts_per_page="5" transition="fade" seo="true" css_classes="call-to-actions" images_loaded="true" preloaded="true" preloaded_amount="4" pause="true" pause_override="true"]
The following Repeater Template was used to create the CTA Example: Featured Content example.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
<li class="alm-cta cta-callout"> <?php if($alm_item == 2){ $slug = 'rest-api'; }elseif($alm_item == 7){ $slug = 'custom-repeaters'; }elseif($alm_item == 12){ $slug = 'cache'; }elseif($alm_item == 17){ $slug = 'comments'; }else{ $slug = 'search-engine-optimization'; } $args = array( 'name' => $slug, 'post_type' => 'page', 'post_status' => 'publish', 'posts_per_page' => 1 ); $cta = get_posts($args); if( $cta ) { $id = $cta[0]->ID; ?> <a href="<?php echo get_permalink($id); ?>"> <div class="details"> <h4><?php echo get_the_title($id); ?></h4> <p><?php the_field('subtitle', $id); ?></p> <p class="btn">Learn More</p> </div> </a> <?php } ?> </li> |