Dynamically Insert Image Into Stylesheet

Typically with themes that support custom styles/images, you define everything you can in your stylesheet, and then add the dynamic styles inline: .header { background-position: 50% 50%; background-repeat: no-repeat: background-size: whatever; } And in your templates: <div class=”header”<?php if ( $image ) printf( ‘ style=”background-image: url(%s);”‘, $image ) ?>> Title </div>

How to create an ACF shortcode with Repeater Field in WordPress? [duplicate]

you need to return your code when using shortcodes. Additionally you didn’t close the function. try this: function menu_loop() { $menu = ‘<div class=”entry-content dishes”>’; // check if the repeater field has rows of data if (have_rows(‘menu_sections’)): // loop through the rows of data while (have_rows(‘menu_sections’)) : the_row(); // display a sub field value $menu … Read more

Hide ACF from source code until a “show” button is clicked

You’re going to need to $.ajax() the contents of the field(s) on a click. In a nutshell: In your page template <?php global $post; $post_id = $post->ID; ?> <button class=”acf-get-content-button”>Let’s see that content</button> <div id=”acf-content-wrapper” data-id=”<?php echo $post_id; ?>”></div> JS (function($) { $(‘.acf-get-content-button’).click(function(e){ e.preventDefault(); var $contentWrapper = $( ‘#acf-content-wrapper’ ); var postId = $contentWrapper.data( ‘id’ … Read more

Sort a custom post with ACF: Date Picker & Display Featured!

Please change your args like this. $meta_query = array( array( ‘key’ => ‘event_type’, ‘value’ => ‘featured’, ‘compare’ => ‘=’ ) ); $args = array( ‘post_type’ => ‘event’, ‘posts_per_page’ => -1, ‘order’ => ‘DESC’, ‘orderby’ => ‘meta_value_num’, ‘meta_key’ => ‘event_date’, ‘meta_query’ => $meta_query );

WP User Query with Custom Fields and Search Results

Not sure if you ever found the answer, but just in case, I just did 🙂 There’s a hook I (finally!) found that lets you do this and works in a similar way to posts_where. The hook is pre_user_query. Here’s an example on the Codex: https://developer.wordpress.org/reference/hooks/pre_user_query/#user-contributed-notes With the above, your function could now look like … Read more

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