Bulk update wordpress posts

One implementation detail of how WP works with database is that it always drags all query results into PHP values and memory space. In other words it is highly unlikely to throw any heavy query at WP and not have it collapse. Notably any plugins that deal with large queries (such as database backup ones) … Read more

How to create bootstrap grid loop?

Okay I got it! And this code works perfectly for me. 🙂 <?php $args=array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 4, ‘paged’ => $paged, ‘tax_query’ => array( array( ‘taxonomy’ => ‘post_format’, ‘field’ => ‘slug’, ‘terms’ => array(‘post-format-video’), ‘operator’ => ‘IN’) ) ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) { $i = 0; … Read more

Second get_permalink inside loop points to wrong URL

get_permalink doesn’t output anything, it returns the permalink. Your first call works because you use it within the_title, which echos its value along with any before and after parameters you pass to it. Change your second instance to: <?php echo get_permalink(); ?> or use the_permalink, which echos the value instead of returning. <?php the_permalink(); ?> … Read more

Showing categories and subcategories with posts

Update: Complete code <ul> <?php $get_parent_cats = array( ‘parent’ => ‘0’ //get top level categories only ); $all_categories = get_categories( $get_parent_cats );//get parent categories foreach( $all_categories as $single_category ){ //for each category, get the ID $catID = $single_category->cat_ID; echo ‘<li><a href=”https://wordpress.stackexchange.com/questions/270176/” . get_category_link( $catID ) . “https://wordpress.stackexchange.com/questions/270176/”>’ . $single_category->name . ‘</a>’; //category name & link … Read more

How to loop through all the attached images in a post, and get their url one by one

Put this in the template file at the beginning or in functions.php file: function get_images_attachment_url() { global $post; $images_urls = array(); $images_objects = get_attached_media( ‘image’, $post->ID ); foreach ($images_objects as $image_object) { $images_urls[] = wp_get_attachment_url ($image_object->ID); } return $images_urls; } When you need to call them use foreach after calling the function get_images_attachment_url(): $my_images_urls = … Read more

Loop inside query

This is a PHP syntax error – you can’t nest a foreach inside an array, you use it to build the array: $query = [ ‘post_type’ => $post_type, ‘posts_per_page’ => -1, ‘tax_query’ => [ ‘relation’ => ‘OR’, ], ]; foreach ( $taxonomy_arr as $t ) { $query[‘tax_query’][] = [ ‘taxonomy’ => $t[‘taxonomy’], ‘terms’ => $t[‘value’], … Read more

ACF – add a group inside a repeater [closed]

You code looks very confusing. Why are you using the ‘foreach’? If you follow the ACF documentation, you just need to use: <?php if( have_rows(‘questions’) ): while( have_rows(‘questions’) ): the_row(); // vars $repeater-item = get_sub_field(‘repeater-item’); ?> <div class=”content”> <?php the_sub_field(‘caption’); ?> </div> For the group. Source: https://www.advancedcustomfields.com/resources/group/ And you only have to use: if( have_rows(‘item’) … Read more