Custom Post Type without an archive page

Is this a WordPress feature? Yes, and the redirect is being done by redirect_canonical(), but the URL is determined by redirect_guess_404_permalink(): redirect_guess_404_permalink() Attempts to guess the correct URL for a 404 request based on query vars. So what’s happening in your case is, WordPress attempts to find a post having book in the slug (post_name), … Read more

API response to be stored locally

Sure, you can store it in a transient for a day. <?php $list_items = get_transient( ‘my_list_items’ ); if ( false === $list_items ) { // Assume “$list_api->get_items()” connects to an API. $list_items = $list_api->get_items(); set_transient( ‘my_list_items’, $list_items, DAY_IN_SECONDS ); } if(!empty($list_items)) { foreach($list_items as $list_item) { ?> <div class=”item-container”> <h2><?php echo $list_item[‘title’]; ?></h2> <p><?php echo … Read more

Settings API – sanitize_callback is not called and it leads to an incorrect behavior

If I take the value sanitize_callback out of the argument array completely, everything works as desired, so error-free. Yes, and that’s because you used the wrong callable syntax which then causes PHP to use a global function named sanitize_options instead of the method/function of the same name in your class (i.e. Faqdesk_Settings::sanitize_options()). So to solve … Read more

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