Update
I managed to make it filter based on 2 custom fields, but it is not searching by title now
function filter_products_by_sku( $args, $field, $post_id ) {
$the_search = $args['s'];
unset($args['s']);
$args['meta_query'] = array(
'relation' => 'OR',
array(
'key' => 'sku_number',
'value' => $the_search,
'compare' => 'LIKE',
),
array(
'key' => 'old_id',
'value' => $the_search,
'compare' => 'LIKE',
)
);
return $args;
}
add_filter('acf/fields/post_object/query/key=field_5f58a23b95d62', 'filter_products_by_sku', 10, 3);
Thank you!
I forgot to mention that the MODEL field was not a ACF field. I have added the MODEL field a acf-field_xxxx identifier, and now it works as intended.
Thank you for taking your time to answer me!
Thank you, you saved me!
Thank you. I allready solves it,but your code looks cleaner than mine.
I wqs trying to build a plugin that displays a calendar with cpt and acf custom date.
I got everithing working, so if anyone needs it,ask it here.
I will also upload it to wp repository,since i saw a lot of people wqs looking for something like that.
You are awsome!!
Thank you verry much!
Thank you for your shortcode, it works flawless!
The reason i am writing you is to ask if you can extract the street address as well, along with the city and country.
I would only need the street address and city.
Please let me know if there is anyway to get that field.
Thank you!
You are right.
I just edited that file, removed that code and now it runs perfectly!
Thank you verry much for helping me out!
And for everibody else who is reading this, i am using schema theme, and the error was in /wp-content/themes/schema/js/customscript.js == i just deleted the first 7 lines.
Thank you again Jonathan!
I will try to find andd remove that code, and then change the theme
I`ll let you know how things go.
Thank you for taking time to help me out.. you are awsome!
Would it help you if i grant you access to my admin area?
And this is the code i am using on that page template :
<?php
/**
* Template Name: Vinde Moto
*/
?>
<?php acf_form_head(); ?>
<?php get_header(); ?>
<div id=”page” class=”single”>
<article class=”<?php mts_article_class(); ?>”>
<div id=”content_box” >
<div id=”primary”>
<div id=”content” role=”main”>
<?php /* The loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<?php acf_form(array(
‘post_id’ => ‘new_post’,
‘post_title’ => true,
‘new_post’ => array(
‘post_type’ => ‘moto’,
‘post_status’ => ‘publish’
),
‘return’ => ‘/anunt-publicat’,
‘updated_message’ => __(“Post updated”, ‘acf’),
‘submit_value’ => ‘Listeaza’
)); ?>
<?php endwhile; ?>
</div><!– #content –>
</div><!– #primary –>
</div>
</article>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Sorry.. it was a typo mistake
Look here : http://everkoop.nl/moto/vinde-moto/
Hello Jonathan and thank you for trying to help me out.
I am using acf pro 5.0.8 and i did placed that code before the get_header.
However,the form gets displayed,but several fields are not working properly,like the map or the logical fields.
Please have a look at ecerkoop.nl/moto/vinde-moto
i comed up with this code, but it only calculates the sum of the posts on that page or category
$factorTotal = 0;
$factorCount = 0;
while ( have_posts() ) : the_post();
$factorI = get_field(‘price’, $post->ID);
if($factorI){ // Only if it exists
$factorTotal += $factorI; // Add it
$factorCount++; // Count it
} // end if
endwhile;
echo ‘Total Value: ‘. $factorTotal .’ $’;
I need it to calculate the sum of custom field ‘price’ that is in all of my posts
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.