ACF Field, hide taxonomy title and image when no nothing selected in post

Seems the your post doesn’t attach any taxonomy. So just try to replace your code with this: <?php global $post; $tax = ‘directory_features’; $terms = get_the_terms($post,$tax); if ( $terms && ! is_wp_error( $terms ) ){ foreach( $terms as $term ) { $term_link = get_term_link( $term ); $image = get_field(‘svcta_favorites_image’,$term); if( $term->count > 0 ) { … Read more

advanced custom fields if field has value show main div [closed]

Please try below and let me know if any query. <?php if( get_field(‘packaging_details’) || get_field(‘port’) || get_field(‘lead_time’)): ?> <div class=”prd-overview-list”> <h3>Packaging & Delivery</h3> <ul> <?php if( get_field(‘packaging_details’) ): ?><li><p>Packaging Details</p> <p><span><?php the_field( ‘packaging_details’ ); ?></span></p></li><?php endif; ?> <?php if( get_field(‘port’) ): ?><li><p>Port</p> <p><span><?php the_field( ‘port’ ); ?></span></p></li><?php endif; ?> <?php if( get_field(‘lead_time’) ): ?><li><p>Lead Time</p> … Read more

Create Shortcode for php code in functions.php

If your code works fine then do this in function.php <?php add_shortcode( ‘custom_name’, ‘footag_func’ ); function footag_func( $atts ) { $html=””; $posts = get_field(‘related_posts’, false, false); $loop = new WP_Query(array(‘post_type’ => ‘post’, ‘posts_per_page’ => 3, ‘post__in’ => $posts, ‘post_status’ => ‘publish’, ‘orderby’ => ‘post__in’, ‘order’ => ‘ASC’ )); if($loop->have_posts()) { $html .= ‘<div class=”rel-posts”>’; while … Read more

Redirect based on referer using Advanced Custom Fields

Try the template_redirect hook function portal_protection() { if ( get_field(‘enable_portal_protection’) && !current_user_can(‘administrator’) ) { $referring_url = get_field(‘referring_url’); $redirect_url = get_field(‘redirect_url’); $referer = $_SERVER[‘HTTP_REFERER’]; if ( $referer != $referring_url) { wp_redirect( $redirect_url ); exit; } } } add_action( ‘template_redirect’, ‘portal_protection’ ); Also use wp_redirect. it’s the WordPress way of redirecting.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)