ACF custom field in [closed]

In the header.php template, you cannot access the $post variable. So you will have to map it using $wp_query, as mentioned on ACF forum here. Try this: <?php global $wp_query; $post = $wp_query->post; $background = get_field(‘background’, $post->ID); ?> <style> .site-header { background: url(<?php echo $background; ?>) no-repeat center; background-size: cover; } </style>

ACF add custom fields to categories and display

Check this page out from the ACF docs: https://www.advancedcustomfields.com/resources/get-values-from-a-taxonomy-term/ Specifically this section: “Finding the term related to the current post” <?php // load all ‘category’ terms for the post $terms = get_the_terms( get_the_ID(), ‘category’); // we will use the first term to load ACF data from if( !empty($terms) ) { $term = array_pop($terms); $custom_field = … Read more

Adavnced custom fields relationship query plus query inside

Looks like you’re using both get_posts() and new WP_Query() — You only need one or the other. You’re also using WP_Query() incorrectly — It’s looking for an array of arguments, but you’re passing $videos, which is an array of post objects. Try this: <?php $args = array( ‘post_type’ => ‘videos’, ‘meta_query’ => array( ‘relation’ => … Read more

WebP Fallback for Inline Background Image in Style Attribute

Here’s couple of wild ideas which you could try, if you’re feeling adventurous. 1) Write some conditional logic with $_SERVER to detect if the user’s browser is the right type and high enough version, that would probably support the WebP format. Try using $_SERVER [‘HTTP_USER_AGENT’] and see also https://stackoverflow.com/questions/13252603/how-does-http-user-agent-work 2) Add the WebP and fallback … Read more

Sort by page information by Ascending Numbers

Use custom fields wp_query Ex <?php $args = array( ‘post_type’ => ‘page’, ‘meta_query’ => array( array( ‘key’ => ‘mytitle’, ‘value’ => ‘title’, ‘orderby’ => ‘mytitle’, ‘order’ => ‘DESC’ ), ) ); $query = new WP_Query( $args ); if ( have_posts() ) while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?> <tr> <td><?php echo the_field(‘educational_ranking’); ?></td> <td><a href=”https://wordpress.stackexchange.com/questions/60150/<?php … Read more

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