Inserting HTML tag with ACF into shortcode

You have to use do_shortcode() to execute shortcodes in your string Full code should be like that <?php function my_shortcode( $atts ) { $atts = shortcode_atts( array( ‘post_id’ => ”, // Default value. ), $atts ); $output=”https://wordpress.stackexchange.com/questions/291524/[acf field=”image” post_id=”” . $atts[‘post_id’] . ‘”]’; $output = do_shortcode( $output ); $output=”<img src=”” . $output . ‘” />’; … Read more

How can I store a file in the database in the same way WordPress and ACF do?

ACF doesn’t store any file in Database, it simply provides meta fields with user friendly interface. You can however, store them yourself. To store a field, you need to be familiar with PHP a bit. Here’s how saving a meta field happens, by using the add_post_meta() function: add_post_meta ( $post_id, ‘meta_key’, ‘meta_value’, $is_unique ); There … Read more

get_posts of Custom Post Type AND Custom Taxonomy

You use multiple taxonomies at once, so use’relation’ => ‘AND’: <?php $args = array( ‘posts_per_page’ => -1, ‘post_type’ => ‘products’, ‘post_status’ => ‘publish’, ‘tax_query’ => array( ‘relation’ => ‘AND’, // this is what was missing array( ‘taxonomy’ => ‘subjects’, ‘field’ => ‘name’, ‘terms’ => $shortcode_atts[‘subject’], ), array( ‘taxonomy’ => ‘plans’, ‘field’ => ‘name’, ‘terms’ => … Read more

ACF page while loop breaks footer while loop

Looks like you need to add ‘option’ to your footer the_sub_field() calls: <p><a href=”https://wordpress.stackexchange.com/questions/307577/<?php the_sub_field(“footer_link’, ‘option’); ?>”><?php the_sub_field(‘footer_link_name’, ‘option’); ?></a></p> var_dump() is used to dump a variable, not a string, so you would need to do something like var_dump($test) for that line to work. You are probably getting errors and warnings in your PHP log … Read more

How can I add multiple ‘tax_query’ arrays via a loop?

OK, I have no idea how and why your code should work… It has nothing in common with correct PHP syntax… But it’s pretty good pseudo-code, so I think I can guess, what you wanted to achieve… $tax_query = array(); if ( have_rows(‘category_taxonomies’) ) { while ( have_rows(‘category_taxonomies’) ) { the_row(); $tax_query[] = array( ‘taxonomy’ … Read more

Loop through custom fields with similar label / common chars in label

You display data in loop, so all item have the same ID div id=”demo”. Add some suffix to make them unique. For example: $lang = substr($field[‘name’], strpos($field[‘name’], “_”); echo ‘<button data-toggle=”collapse” data-target=”#demo-‘. $lang .'”> ….’; echo ‘<div id=”demo-‘. $lang .'” class=”collapse”> …</div>’ Edit Audio doesn’t work inside the collapse panel because key $name never meets … Read more

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