ACF: Only get first row of a Repeater Field

ACF has a function called get_row_index() that you can utilize. Here is how you can possibly use it in your case <?php $active=”active”; while ( have_rows(‘images’) ) : the_row(); $image = get_sub_field(‘image’); if(get_row_index() == ‘1’ ): ?> <img src=”<?php echo get_template_directory_uri(); ?>/files/images/<? php the_sub_field(‘image’); ?>” class=”img-fluid is-slider-item” /> break; <?php $active=””; endwhile; ?> <?php endif; … Read more

Is there a built in function to see if a URLis oEmbed Compatible?

wp-includes/class-oembed.php has a public variable $providers. So you can build a small function to get all of them: function list_oembed_providers( $print = TRUE ) { require_once( ABSPATH . WPINC . ‘/class-oembed.php’ ); $oembed = _wp_oembed_get_object(); $print and print ‘<pre>’ . htmlspecialchars( var_export( $oembed->providers, TRUE ) ) . ‘</pre>’; return $oembed->providers; } If you call this … Read more

Limit get_pages to only show 5 items

I have had similar problems with the number attribute in get_pages() I got around it by using get_children: $pages = get_children(array( ‘numberposts’ =>1, ‘post_parent’ => $heading_page->post_id )); and using post_parent instead of child_of.

WordPress override bloginfo variable

For the example you mentioned, you can add a filter to the stylesheet_directory hook add_filter(‘stylesheet_directory’,’change_stylesheet_dir’) ; function change_stylesheet_dir($stylesheet_dir, $stylesheet, $theme_root) { # do stuff – change the stylesheet directory $new_stylesheet_directory = ‘http://mysites.com/hello/’; return new_stylesheet_directory ; } For any of the other parameters for bloginfo, you can look at the code for for bloginfo, which is … Read more

Custom excerpt function re-factoring

I’d simply set a flag as second input argument for the function: function new_wp_trim_excerpt( $text, $case=”plain” ) { switch ( $case ) { default : case ‘plain’ : // do stuff – your function so far break; case ‘image’ : break; } } Notes: Avoid names like class=”moarplz”. It’s hard to read for others and … Read more