How to share repeated fields across multiple pages?

The ACF functions accept a second argument which is the ID of the page you wish to retrieve the fields from. See the code examples in documentation. $page_id = 120; if( get_field( ‘treatments’, $page_id ) ): while( has_sub_field( ‘treatments’, $page_id ) ): // the_sub_field and get_sub_field don’t need a post id parameter the_sub_field(‘image’ ); the_sub_field(‘description’ … Read more

How do I run through a WordPress loop called from a filter function?

When using a custom query, in order to access the $post information, you need to reference post as a class variable the custom WP_Query. Since you constructed the query as: $hw_selectbox_query = new WP_Query($hw_selectbox_args); Then you would access the post variable of $hw_selectbox_query, like so: var_dump($hw_selectbox_query->post); This will give you the information you need / … Read more

Can I wrap an unordered list inside a shortcode?

You can capture the list in a variable, rather than echo it: $list=”<ul class=”strong”> <li>” . get_field( ‘highlights_list_item#1’ ) . ‘</li> <li>’ . get_field( ‘highlights_list_item#2’ ) . ‘</li> </ul>’; echo do_shortcode( ‘[one_half]’ . $list . ‘[/one_half]’ ); Note the use of get_field() rather than the_field(), which returns a custom field value as opposed to displaying … Read more

Display PHP within HTML values

If the function returns a printed value: <a href=”https://wordpress.stackexchange.com/questions/145222/<?php bloginfo(“url’); ?>”>Link</a> If not (using the echo statement): <a href=”https://wordpress.stackexchange.com/questions/145222/<?php echo get_stylesheet_directory_uri(); ?>”>Link</a> You can also use print() as part of a more complex expression where echo cannot. By the contrary, when you want to use HTML into PHP, I recommend to close PHP and open … Read more

Problem with WordPress query on page using custom fields

Edit :// try this: <?php add_filter( ‘genesis_pre_get_option_site_layout’, ‘__genesis_return_full_width_content’ ); function sk_display_custom_fields() { /*Wordpress loop*/ global $wp_query; query_posts(array( ‘post_type’ => ‘sammenligne’ )); while(have_posts()) : the_post(); ?> $navn = get_field( ‘navn’ ); $type = get_field( ‘type’ ); echo ‘<p>’,$navn , ‘__’, ‘$type’,'</p>’); endwhile; wp_reset_query(); } add_action( ‘genesis_entry_header’, ‘sk_display_custom_fields’ ); genesis(); UPDATE:// Ok I tested ACF’s now. With … Read more

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