I want to show the category image (set with ACF) inside a loop that shows it inside the cards, how can I do it?

<?php get_header();   $  category = get_category( get_query_var( 'cat' ) ); $  cat_id = $  category->cat_ID;  $  id_cat = array('parent' => $  cat_id); $  categories = get_categories( $  id_cat ); 

// Get particular category’s object info. $ queried_object = get_queried_object();

// (Optional depending on desired outcome) If you wanted to get the type of taxonomy. $ taxonomy = $ queried_object->taxonomy;

// (Optional depending on desired outcome) If you wanted to get the associated ID. $ term_id = $ queried_object->term_id;

// Get image ID for this field. $ attachment_id = get_field( ‘category_image’, $ queried_object );

// URL of image at specific size. $ image = $ attachment_id[‘sizes’][‘chosen-image-size’];

<section class="p-5">     <div class="container">         <div class="row text-center">             <h3><?php single_cat_title(); ?></h3>             <p><?php category_description(); ?></p>         </div>     </div> </section>  <section>     <div class="container animated">         <div class="row d-flex" data-masonry='{"percentPosition": true }'> 

‘.’ term_id ).'”>’ .$ category->name.”.’ ‘; } ?>

In evidenza

            <?php while(have_posts()): the_post(); ?>                 <div class="col-6 col-md-4 col-xl-3 mb-4">                     <div class="card text-center">                         <a href="<?php the_permalink() ?>">                                         <!-- Immagine Articolo -->                             <?php if(has_post_thumbnail()): ?>                                   <div class="m-1"><?php the_post_thumbnail('thumbnail') ?></div>                             <?php endif; ?>                         </a>                             <div>                             <h3><?php the_title(); ?></h3>                             <p><?php the_excerpt(); ?></p>                         </div>                         <a href="<?php the_permalink() ?>" class="btn btn-outline-dark btn-sm">Continua a                             Leggere</a>                     </div>                 </div>                     <?php endwhile; ?>                     <?php else: ?>                         <?php echo wpautop('ops.. non ho trovato nulla');?>                     <?php endif; ?>         </div>     </div> </section> 

Saving data from for loop to file and then read the data and plot graphs

I have a for loop which generates random matrices, then performs a few calculations to yield a bunch of different values. Essentially, something like so: For[j = 1, j < 100, j++, a={{1}{2}{3}{4}},b={{5}{6}{7}{8}},c=Tr[a],d=Tr[b], e=c+d, {a,b,c,d,e}>>> file]

Of course in the above, we repeat the same values over and over, I am using this as an example as the script would be too long and requires a list of different packages. I need to save these values to a file in a way that I can then extract the values and create a bunch of different graphs. What is the best way to go about this?

How to loop nav menu items in WordPress menu Walker?

I want to loop every single item in the menu with the walker class.

class Primary_Walker_Nav_Menu extends Walker_Nav_Menu {     public $  bg;      function __construct() {         $  this->bg = get_field('navigation_menu_background_image', 'option'); //acf array in function.php     }           } 

In $ this->bg are an array of images, I want to have $ depth less from 0, which means the only the first item in-depth, not sub-menu, nothing else.

My idea is to loop $ i item and get $ bg item on position $ i, how to do this?

Help, thanks!

help with while loop

Hi, in changeing from MYSQL to MYSQLi (that's where the blame goes) I can't get a clear understanding as to the proper code
for the while loop. help please. code follows:
<center><b><font size=+2> 515 Certification Expiration Report</font><br>06/22/2020 – 06/22/2021<p>


//Open a new connection to the MySQL server
require_once "getprerentdb.php";

//MySqli Select Query
$ results = $ mysqli->query (SELECT * FROM…

help with while loop

Change query based on post type while staying in loop

I have a loop that displays three custom post types.

Thing is, all of these post types use a different logic. ‘elemzesek’ and ‘gyorshirek’ use ACF fields which you can see in the meta_query.

However, the ‘cikkek’ post type, to display the correct articles, would need a

‘tag’ => get_the_title();

The problem is, if this is added, and it runs for ‘elemzesek’ and ‘gyorshirek’ as well, the loops finds no results.

Can someone help me in achieving this?

<?php      $  ceg = get_the_title();     $  ceg_megadasa = get_field('ceg_megadasa');     $  paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;     $  query = new WP_Query( array(         'post_type' => array('cikkek', 'elemzesek', 'gyorshirek'),         'posts_per_page' => 10,         'paged' => $  paged,         'post_status' => 'publish',         // 'tag' => $  ceg,         'orderby' => 'date',         'order' => 'DESC',         'meta_query' => array(             'relation' => 'OR',             array(                 'key' => 'ceg_megadasa',                 'value' => get_the_ID()             ),             array(                     'key' => 'ceg_megadasa_gyorshirek',                     'value' => get_the_ID()                 ),                      )     ) ); ?> 

Change AJAX Live Post Search Loop into foreach

I was told that the reason for why the live post search does not work is because the loop needs changing into a foreach.

This is the code:

add_action( 'wp_ajax_data_fetch' , 'data_fetch' ); add_action( 'wp_ajax_nopriv_data_fetch', 'data_fetch' ); function data_fetch() {      global $  wpdb;     $  post_search_query = $  wpdb->get_results("SELECT * FROM wp_posts where post_type = 'post' and post_title like '%'".esc_attr( $  _POST['search_keyword'] )."'%'");          if( $  post_search_query->have_posts() ) :                  while( $  post_search_query->have_posts() ): $  post_search_query->the_post(); ?>                          <h5><a href="<?php echo esc_url( post_permalink() ); ?>"><?php the_title();?></a></h5>             <span class="live-search-product-excerpt"><?php the_excerpt(); ?></span>              <?php endwhile;         wp_reset_postdata();     endif;     die(); } 

The search is dead. It shows nothing. Can someone please help me with this as I am at a loss. Here is the rest of the code:

add_shortcode('live_search', 'live_search_shortcode'); function live_search_shortcode(){      $  live_search = '<input type="text" class="live-search" name="postSearch" id="postSearch" placeholder="Type to Live Search"></input>     <div id="datafetch"></div>';          return $  live_search; }  add_action('wp_footer', 'jquery_live_search_data_fetch'); function jquery_live_search_data_fetch() { ?>      <script type="text/javascript">                  (function($  ){              var searchRequest = null;                                  jQuery(function (){                                      var minlength = 3;                                  jQuery("#postSearch").keyup(function (){                                          var that = this,                                      value = jQuery(this).val();                                  if (value.length >= minlength){                                      if (searchRequest != null)                      searchRequest.abort();                                  searchRequest = jQuery.ajax({                                      type: "POST",                     url: "<?php echo admin_url('admin-ajax.php'); ?>",                 data: {                 action: 'data_fetch',                 search_keyword : value                 },                                  dataType: "html",                 success: function(data){                                          if (value==jQuery(that).val()) {                                              jQuery('#datafetch').html(data);                     }                 }             }         );     } else {      jQuery('#datafetch').html( '' );     }   } ); }); } (jQuery));     </script> <?php } 

Custom Loop with certain number of one category

I have a custom loop that goes like this:

            global $  post;             $  tmp_post = $  post;             $  args = array(              'numberposts' => '120',             'orderby' => 'date',             'order'   => 'DESC',             'cat' => array(1,2,7,8,9,27, 30, 31),             'tax_query' => array(                         array(                             'taxonomy' => 'post_format',                             'field' => 'slug',                             'terms' => array( 'post-format-aside','post-format-video' ),                             'operator' => 'NOT IN',                         ),                     )          );             $  myposts = get_posts( $  args );             foreach( $  myposts as $  post ) : setup_postdata($  post);          ?> 

What I need is not a output of 120 posts in total, but 120 posts only of the category with the ID 2. Is that possible?