Portfolio items created indefinitely from external API. Every time different number

I am trying to make new portfolio item for every json item from external api. I am working on WordPress and placed my code in functions.php of the theme used. When i run my code, it creates portfolio items more than necessary. The items seem to randomly get duplicated even tho i have made validation statement and made sure that each post lug is unique. I want it to stop when the array in json file finishes. Unfortunately I can’t share the api link because it is not supposed to be open-source. It consists of one page. $ model and $ results get correct info. I am new to these WP functions and API thing and got really confused at this point. Hope someone can help me out!:

add_action('wp_ajax_nopriv_get_3dmodels_from_api', 'get_3dmodels_from_api'); add_action('wp_ajax_get_3dmodels_from_api', 'get_3dmodels_from_api');  function get_3dmodels_from_api(){          $  results = wp_remote_retrieve_body(wp_remote_get('<api-url-here>',  array(         'timeout'     => 120,         'httpversion' => '1.1',     ) ) );            $  results = json_decode($  results);     //print_r($  results);           foreach($  results->scenes as $  model) {                  $  model_slug = sanitize_title($  model->name. '-' . $  model->id);                  $  existing_model = get_page_by_path($  model_slug, 'OBJECT', 'portfolio');          if ($  existing_model === null) {              $  inserted_model = wp_insert_post([                 'post_name'=> $  model_slug,                 'post_title'=> $  model_slug,                 'post_type'=> 'portfolio',                 'post_status' => 'publish',             ]);                          if (is_wp_error($  inserted_model)) {                 return false;             }                      $  fillable = [                 'field_605dcef7001bc' => 'name',                 'field_605dcf01001bd' => 'description',                 'field_605dcf09001be' => 'category',                 'field_605dcf13001bf' => 'preview',             ];                          foreach($  fillable as $  key => $  name) {                 $  model_content = $  model->$  name;                                  if ($  name == 'preview') {                     $  model_content = '<img src=' . $  model->$  name . '" alt="">';                 }                                  update_field($  key, $  model_content, $  inserted_model);             }         }  wp_remote_post(admin_url ('admin-ajax.php?action=get_3dmodels_from_api'), [         'blocking' => false,         'sslverify' => false,     ]); } 

Thank you!

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!

get_the_excerpt doesn’t work with default items but works with my customs post types

the excerpt function not work in my custom post template using WordPress default posts in the query loop, but they work fine with custom post type.

I enabled the display of excerpt by checking the "excerpt" option in the post options fields.

I also added "add_post_type_support(‘page’ ‘excerpt’)" in my function.php file but it doesn’t working.

I suspect a problem coming from the database because the excerpts are displayed when I test the website locally with Xampp.

Here is a snippet of the code used in my page template:

<div class="container">                      <div class="row">                         <div class="col-lg-9 col-mg-9 mp-blog" style="padding-right: 24px;">                                                 <div class="row">                                  <?php                                 $  paged = (get_query_var('paged')) ? get_query_var('paged') : 1;                                  $  args = array(                                   'post_type'=>'post', // Your post type name                                   'posts_per_page' => 6,                                   'cat' => 26,                                   'paged' => $  paged,                                 );                                                                  $  loop = new WP_Query( $  args );                         if ( $  loop->have_posts() ) {                             while ( $  loop->have_posts() ) : $  loop->the_post();?>                        <?php the_excerpt();?>                        <?php endwhile;                              $  total_pages = $  loop->max_num_pages;      if ($  total_pages > 1){          $  current_page = max(1, get_query_var('paged'));     ?>     <div class="custom_pagination">        <?php         echo paginate_links(array(             'base' => get_pagenum_link(1) . '%_%',             'format' => '/page/%#%',             'current' => $  current_page,             'total' => $  total_pages,             'prev_text'    => __('« précédent'),             'next_text'    => __('suivant »'),         ));?>     </div>     <?php }     } wp_reset_postdata();?>                     </div>                 </div><!-------------- end of col-8 ------------------>               <div class="col-lg-3 col-mg-3" style="padding: 0;">                   <div id="tching" class="blog_right_sidebar" style="padding: 0 15px;">                       <?php get_sidebar(); ?>                   </div>               </div>             </div>          </div> 

Are the Book of Shadow or Genie’s Vessel granted by Warlock features considered as magic items?

Basically the title.

If a Warlock fights by wielding their Book of Shadow or Genie Vessel in one hand as a spell focus and keeps the other one empty to meet the requirement of somatic component, they will eventually end up in situations where they are forced to use the book or vessel as an improvised weapon (like when an enemy closed the distance or when the Warlock needs to perform an Opportunity Attack). So the question is, would hitting someone with the spine of the book of shadow or their oil lamp of a Genie Vessel be considered using an improvised weapon with magical properties?

For the Vessel, It is a tiny object, but not specifically written as "a magical tiny object" even if the previous sentence mention that the patron has imbued magical powers with it. The Warlock can do lots of wacky stuff with it like sleeping in it or dragging others into it to rest, but it almost seems like its the power of the Class Feature using the item in question as the medium in which the feature’s power (and thus your Patron’s power) is expressed, and not the power of the Item proper.

Genie’s Vessel ; 1st-level Genie feature ; Your patron gifts you a magical vessel that grants you a measure of the genie’s power. The vessel is a Tiny object, and you can use it as a spellcasting focus for your warlock spells. You decide what the object is, or you can determine what it is randomly by rolling on the Genie’s Vessel table.

The book of shadow is even more vague; it is only stated to be a grimoire, and nothing else about it’s materalistic properties are mentioned or explained further other than that if its lost or destroyed you can resummon it. How durable is it, anyway?

This also opens some icky boxes like "Would anti-magic fields suppress their magical properties or destroy them outright?" and something like "If the Genie’s Vessel is indeed a magic item and using it as an improvised weapon can pierce resistance, the Genie Warlock has access to a magical weapon that is basically the equivalent of a +0 but magical dagger at LV1" etc.

I am aware that some similar questions have been asked, like "Does attacking with an improvised weapon using a magic item count as a magical attack?" and "Are punches with Gauntlets of Ogre Strength magical, improvised weapon attacks?"; but the main issue here is that the vessel’s status as a separate magical item seems to be a bit unclear.

PS: Before someone says that using it as an improvised weapon is a poor choice of tactics, keep in mind that Genie Warlocks gain extra damage from the "Genie’s Wrath" Feature equal to their proficiency bonus. Compared to wielding a regular dagger with the damage of 1d4 + dex + pb, using the Genie’s Vessel as an improvised weapon of 1d4 + str + pb isn’t that bad; and depending on how the DM would rule it could be counted as magical and be able to pierce resistances.

Are there any ways to increase the number of items I can attune to without being an Artificer?

The problem is quite simple: I want to attune to four or more magical items at once, and I don’t want to take ten levels in Artificer.

Are there any features, items, etc. that increase the number of items you can attune to without being a 10th level or higher artificer?

Does an artificer’s teammate have to re-attune to their infused items every time the infusions change?

Per the artificer rules…

If the item requires attunement, you can attune yourself to it the instant you infuse the item.

Okay. Nice. Great. Except… how does it work when the item is given to another character?

Let’s picture these scenarios: Scenario one. My artificer has created an Resistant Armor, choosing poison. This armor has been given to our paladin, who attuned to it. Now, next long rest, I want to create an Resistant Armor, choosing force. The rules are silent on whether I can attempt to create an infusion I already have existing (as opposed to infusing random other infusions until that one de-infuses) or in fact use the item the previous copy of that infusion is already on. Let’s assume I can.

… but I don’t want to attune to the resulting infusion, so does that mean that, as soon as we finish the long rest, we must immediately do a short rest so the paladin can attune to the armor?

In fact, it doesn’t even end there!

If you try to exceed your maximum number of infusions, the oldest infusion ends, and then the new infusion applies.

Notably, there doesn’t seem to be a process to voluntarily end one of my infusions. Let’s suppose my current infusions are Repeating Weapon, Replicate Magic Item: Alchemy Jug and the aforementioned Resistant Armor: Force. I want to replace the jug with a Mind Sharpener. The only process for this seems to be infusing my chosen item with the Mind Sharpener, causing the Repeating Weapon to end…. then reapply the Repeating Weapon…. which ends the Resistant Armor, requiring me to reapply that, and us to take another short rest to reattune to it!

Is all the above correct, or is there something I’m missing?

(5e) Are there any magic items that allow a user to bypass fire resistance with a magical weapon?

A bit of a specific request I know, but for an upcoming battle my DM is throwing at us, I’ll be using a magical weapon that deals fire damage and we know the creature has fire resistance. So I was wondering if there were any options to ignore the opponent’s fire resistance. I know of the Elemental Bane spell already, but if there were any other spells that had this effect as well that would be helpful to know as well.

Is the Pit from a Robe of Useful Items permanent and can it be dispelled?

If you place the Pit from the Robe of Useful Items, will it remain there forever, as if it was dug? RAW, I assume so. The RAW on the Robe of Useful Items doesn’t say anything about the items being temporary, so we should assume they are not.

I’m less convinced on Dispel Magic, and I know I will have to make a ruling on this, likely in a session or two, but I am leaning toward no. If the patch has "become the object or creature", then this is a normal, everyday, non-magical pit. The magic was in it’s creation, not it’s essence. As such, dispel magic would have no effect, right?

Or am I perhaps overlooking something?