New answers tagged

0

What I did was create a custom page template and then incorporated the WooCommerce sidebar function in the template file and the featured image short code in the content. Now I can use ACF to add any new content that I'd like. All the category links and everything in the sidebar still use the WooCommerce template structure.


0

In the settings from that field you can select to output the image URL. If it returns a object, use: $img = get_field( 'brochure_logo' ); And to output the URL, use: echo $img[0]['url']


2

You can pass the term object as the second parameter to the_field/get_field. echo '<img src="' . get_field( 'brochure_logo', $tax_term ) . '">';


0

This is not the way which you have clled for ACF. Parameters <?php $field = get_field($field_name, $post_id, $format_value); ?> $field_name: the name of the field to be retrieved. eg “page_content” (required) $post_id: Specific post ID where your value was entered. Defaults to current post ID (not required). This can also be options / taxonomies / ...


1

This solution works with get_items() in /lib/endpoints/class-wp-rest-posts-controller.php of the v2 WP Rest API. First, you'll want to construct the GET arguments like you would for a new WP_Query(). The easiest way to do this is with http_build_query(). $args = array ( 'filter' => array ( 'meta_query' => array ( 'relation' ...


1

Here is a test i made on Localhost: For security reasons meta query is not allowed on WP Api, first what you have to do is to add meta_query to allowed rest_query by adding this function on your wordpress theme functions.php function api_allow_meta_query( $valid_vars ) { $valid_vars = array_merge( $valid_vars, array( 'meta_query') ); return ...


0

You can do it without Rest API Like this (It is my posts filter) $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'paged' => $paged, 'orderby' => 'date', // сортировка по дате у нас будет в любом случае (но вы можете изменить/доработать это) 'order' => 'DESC', ); // создаём массив ...


0

I ended up with this <?php //get children of page 241 and display with custom fields $args=array( 'post_parent' => 825, 'post_type' => 'page', ); $my_query = null; $my_query = new ...


0

You could have saved yourself a ton of work and just used the Co-Authors Plus plugin. It has a guest author function. You do have to set them up, but there is no account/password for them, and they can have author pages. (I am not affiliated with them, just use it on several sites.)


0

This is untested, but should work. with variables: <?php // check if the repeater field has rows of data if( have_rows('repeater_name') ): // loop through the rows of data while ( have_rows('repeater_name') ) : the_row(); $one = get_sub_field('one'); $two = ...


0

It is really hard to make any specific suggestions without a more detailed knowledge about your specific situation, but whenever I am stuck with a site that is slow for no good reason, I install Query Monitor plugin (https://wordpress.org/plugins/query-monitor/) and look closely at what it says. I use Advanced Custom Fields extensively, and more often than ...


0

Answering my own question again. :P I finally found this Gist that lets me get and set array variables via dot notation: https://gist.github.com/elfet/4713488 So I included the DotNotation class and now my code looks like this (skipping all sorts of error checking here) : $fieldmap_string = 'key1.key2.key3.etc'; $current_page_content = ...


0

setup_postdata()requires a post object such what you would get by using the global $post. You are using a custom field, presumably from ACF, and calling it $post. The problem is that it is not an object. You can use the field $designer in a customised post loop like so: <?php if ( have_posts() ) { while ( have_posts() ) { the_post(); ...


0

I use CMB2 to set up custom fields, and the logic is not so different from ACF in many cases. For my specific use case I've created a very simple but flexible function in order to make a few checks for the taxonomy before displaying the custom field value. Considering one have created a custom field named my_cf for let's say a taxonomy named basic as per ...


0

If you are missing terms, maybe try to show all terms, event those that are not assigned to a post. By default, wordpress does not get terms that are not in a post. get_terms($taxonomy, array('hide_empty' => false));


0

You can add a new field type according to your wishes. See https://www.advancedcustomfields.com/resources/creating-a-new-field-type for details. Note that this article is available for different versions of ACF.


0

As suggested by @Sumit, the problem was in the template: there was a test that prevented the_content() to execute when the content was empty. <?php if ( $page->post_content && have_posts() ) while ( have_posts() ) : the_post(); ?> <?php the_content(); ?> <?php endwhile ?>


0

Currently from your code I can see you are looping for post IDs from 1 to 1000 that isn't good. WordPress have lot of functions by which you can fetch post IDs, content and other information. One of them (according to your need) is get_pages() Check the documentation of get_pages() there are lot of examples. See the Example from above code:- $all_pages = ...


0

Answer found on Stackoverflow. Custom fields need to be called inside the loop like so... while ( $loop -> have_posts() ) : $loop -> the_post(); $modal_header = get_field('modal_header'); $modal_body = get_field('modal_body'); $modal_footer = get_field('modal_footer'); .... Answer from Codeforest


0

Try the following code <?php /* Template Name: Template_Name */ get_header(); $modal_header = get_field('modal_header'); $modal_body = get_field('modal_body'); $modal_footer = get_field('modal_footer'); echo '<pre>';print_r($modal_header);echo '</pre>'; // show the content of filed its for checking purpose. echo ...


0

I hope I understand the question correctly UPDATE `wp_postmeta` SET `meta_value` = replace(meta_value, 'old_value', 'new_value') WHERE `meta_key` LIKE 'your_key' EDIT 1 : i forgot to mention : BACKUP YOUR DATABASE BEFORE ANY TRIAL EDIT 2 : following comment : To copy from one field to another (I got a bit confused with your naming and which value you ...



Top 50 recent answers are included