John thanks for your valuable input. It’s true that I load them on page load for now, as I’m beta testing it right now.. Most probably, it will be a cron-job done in every 10-15 minutes when the project is up separate from the wordpress or woocommerce loop.
Right now, I’m planning to add if else function within the row addition.. I’ll parse the full code once it works perfectly 😉
Alright, if anyone reads this then I got it working.. However, there are problems…
the code is
<?php
$list = get_posts(array(
'post_type' => 'post',
'meta_query' => array(
array(
'key' => 'cat-to-prod', // name of custom field
'value' => '"' . get_the_ID() . '"',
'compare' => 'LIKE'
)
)
));
?>
<?php if( $list ): ?>
<?php foreach( $list as $list ): ?>
<?php
$feeds = get_field('_scrape_original_url', $list->ID);
$row = array(
'field_59dd767200980' => $feeds,
);
$i = add_row('field_59dd765c0097f', $row);
?>
<?php endforeach; ?>
<?php endif; ?>
The problem is that it keeps adding the same values over and over to my repeater field in the product…
<?php
$scat = get_the_term_list( $id_product,”scat”); // I add scat taxonomy for each product to manually publish the Category ID of the blog
$args = array(
‘post_type’ => ‘post’,
‘tax_query’ => array(
array(
‘taxonomy’ => ‘category’,
‘terms’ => array( $scat ),
),
);
// query
$query = new WP_Query( array( ‘cat’ => $args ) );
?>
<?php if( $the_query->have_posts() ): ?>
<?php while( $the_query->have_posts() ) : $the_query->the_post(); ?>
$content = apply_filters(‘the_content’, $post->post_content);
<?php
if( have_rows(‘chapter’) ) {
while( have_rows(‘chapter’) ) {
the_row();
$row = array(
‘link’ => $content ,
);
add_sub_row(‘link’, $row);
}
}
?>
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_query(); ?>
Latest update.. It’s still not working ;(
more update*
<?php
$scat = get_the_term_list( $id_product,”scat”);
$args = array(
‘post_type’ => ‘post’,
‘tax_query’ => array(
array(
‘taxonomy’ => ‘category’,
‘terms’ => array( $scat ),
),
);
// query
$query = new WP_Query( array( ‘cat’ => $args ) );
?>
<?php if( $the_query->have_posts() ): ?>
<?php while( $the_query->have_posts() ) : $the_query->the_post(); ?>
$content = apply_filters(‘the_content’, $post->post_content);
<?php
if( have_rows(‘chapter’) ) {
while( have_rows(‘chapter’) ) {
the_row();
$row = array(
‘link’ => $content ,
);
add_sub_row(‘link’, $row);
}
}
?>
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_query(); ?>
update*
<?php
$scat = get_the_term_list( $id_product,”scat”);
$args = array(
‘post_type’ => ‘post’,
‘tax_query’ => array(
array(
‘taxonomy’ => ‘category’,
‘terms’ => array( $scat ),
),
);
// query
$query = new WP_Query( array( ‘cat’ => $args ) );
?>
<?php if( $the_query->have_posts() ): ?>
<?php while( $the_query->have_posts() ) : $the_query->the_post(); ?>
$content = apply_filters(‘the_content’, $post->post_content);
<?php add_product_meta($product_id, ‘chapter’, $content); ?>
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_query(); ?>
******
it still doesn’t work 🙁
update*
it still doesn’t work thou
<?php
$scat = get_the_term_list( $id_product,”scat”); // I add this ‘scat’ through the product page in Admin Panel by using Custom Taxonomy. It will be the ID of the wordpress category */
// query
$query = new WP_Query( array( ‘cat’ => $scat ) );
?>
<?php if( $the_query->have_posts() ): ?>
<?php while( $the_query->have_posts() ) : $the_query->the_post(); ?>
$content = apply_filters(‘the_content’, $post->post_content);
<?php add_post_meta($post_id, ‘chapter’, $content); ?>
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_query(); ?>
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.