How to Increment ID value within ACF Repeater Field Loop

Try using a “counter” variable for the loop maybe? <?php if ( get_field(‘ingredients-list’) ) { echo ‘<ul class=”ingredientsList”>’; $count=0; while ( has_sub_field(‘ingredients-list’) ) { echo ‘<li class=”ingredient” itemprop=”ingredients”> <label for=”check-‘. $count .'”> <input type=”checkbox” class=”check” id=”check-‘. $count .'”> ‘; if ( get_sub_field(‘quantity’) ) echo ‘<span class=”quantity”>’ . get_sub_field(‘quantity’) . ‘</span> ‘; if ( get_sub_field(‘measurement’) ) … Read more

Link to blog index from template

if you are referring to the ‘posts page’ as set under dashboard – settings – reading: <?php if( get_option( ‘page_for_posts’ ) ) { echo get_permalink( get_option( ‘page_for_posts’ ) ); } else { echo home_url(); } ?>

Calling an image within the theme folder from inside a post/page?

I realize that this was posted about 7 months ago, but in case you’re still looking for a solution to this, add this to your functions.php file: /** * Add a shortcode for the current theme directory * @return string Current theme directory */ function yourtheme_get_theme_directory_uri() { return get_template_directory_uri(); } add_shortcode( ‘themeuri’, ‘yourtheme_get_theme_directory_uri’ ); Then … Read more

Change location of header.php and footer.php

It is not possible to override header/footer via hooks in respective get_header()/get_header() functions. However it is often overlooked that these function allow input and loading different headers. For example get_header( ‘nested/header’ ); will look for header-nested/header.php in theme’s folder. It’s kind of a hack in regards to subdirectory use, but it works. 🙂

Is it safe to include a javascript file in a template’s php file?

As @N00b mentioned Yes, it is safe adding a JS script as long as it doesn’t include any sensitive information. JS is fully exposed to client, you shouldn’t do it anyway. But your situtaion it is better to create a site specific custom plugin and add JS using it. Example : function themeslug_enqueue_style() { wp_enqueue_style( … Read more

Different template for posts of all subcategories of category

You can check if current category is a child of blog category with cat_is_ancestor_of() function or term_is_ancestor_of(), or maybe better, use in_category(), as you are currently doing, but checking child categories as well. add_filter( ‘single_template’, ‘get_custom_cat_template’ ) ; function get_custom_cat_template( $single_template ) { // You want to filter only template for single posts of default … Read more

ACF – Theming Flexible Content

And to add to previous answers, you can not only use get_template_part, but also use it’s second param and combine it with ACFs get_row_layout. So let’s say that somewhere in your template is: <?php while ( have_posts() ) : the_post(); ?> <article> … SOME CODE <?php while ( have_rows( ‘YOUR_FIELD_NAME’ ) ) : the_row(); ?> … Read more