Multisite: menus can’t be added in child sites

It seems that we cannot add menus in child sites in multisite. Did anyone face this issue before?

I have the Menu container enabled in my functions.php

register_nav_menus(     array(         'primary-menu' => __( 'Primary Menu' ),         'secondary-menu' => __( 'Secondary Menu' )     ) ); 

I can add menus to the parent site. But I can’t do it in the child sites even though I can see the Menu container and the Create Menu button.

No menu is created when the Create Menu button is clicked. WordPress just refreshed the page and the menu I tried to create is not present at all.

I have inspected the database of my child site and I can’t find any row for nav_menu_item.

Any ideas?

EDIT:

I also found out that I cannot add any category or tag in my child sites. Why??

Woocommerce Custom Child Page

I have created a page that’s a child of the Shop page in WooCommerce with a permalink http://localhost/website/shop/featured-products/. I know the WordPress hierarchy works with page-{slug}.php and it’ll load that first, but it doesn’t work on this one (page-featured-products.php) because it’s a child of the shop page in WooCommerce.

I also tried page-{id}.php but it doesn’t work as well, but it all works on regular (non-woocommerce Shop child) pages.

handling primary key with large tree, best way to get root id from child table X

I always used database design using this pattern;

root table with PK id1  child1 table with PK id2 FK id1 child2 table with PK id3 FK id2 child3 table with PK id4 FK id3 etc... 

so if i have to get id1 from child5 table I need to traverse all child tables up to the root one (multiple join)

ex;

select root.id from root    inner join child1 ...    inner join child2 ...    inner join child3 ...    inner join child4 ...    inner join child5 ... where child5.id = X 

is that "ok" as a design or there is way to optimize it?

I could see a few way to do it;

  1. bring the idX as a FK in the table that I expect, so I could modified (add the proper FK) down the line to any childX table as needed
  2. just add the FK as I create new table, this seem wasteful, ex; child5 table would have at mininum 4 FK (id1, id2, id3, id4)

with these options i could simply do;

select child5.rootid from child5 where child5.id = X 

questions

  1. is any of my option above is a good thing to do or there is a better way of doing this?
  2. is there any name given to this pattern (so i can search online, i can’t think of any)

Hi, would anybody know what the file name must be for adding html code to a child theme. for example, must the file be custom.php or custom.js

function my_scripts_method() { wp_enqueue_script(       'custom-script',       get_stylesheet_directory_uri() . "/js/custom_script.js        array( 'query' ),'',true );           } add_action( 'wp_enqueue_scripts', 'my_custom_script.js' ); 

Ive tried putting this code in functions.php and header.php to call the javascript. doesn’t work

The countdown javascript animation is in a file named custom_script.js in a folder named js, which is in the child theme folder named wpbdemo. The animation also had css and html, but that is working I think, as the countdown template is showing, its just not doing any movement. So, I think its the javascript code not working. The css is in style.css file and the html is in footer.php.

How to copy an order item meta from the parent to the child order in a Woocommerce Subscription?

I’m running a function hooked to woocommerce_order_status_completed that uses an API to get a phone number and pin from an external source and save that in a meta key on some order items. Some of these order items are subscriptions.

When a Woocommerce subscription renewal order runs automatically, it fires the API and gets a new set of call-in data. I need to check if a completed order is a subscription renewal and if so skip the API call and just get the renewed item’s parent meta data and insert it into the child items meta.

The top portion of the code I have tried here is not working. The API call portion of the code in the else{} is working so I have truncated it.

add_action ( 'woocommerce_order_status_completed', 'add_item_meta_or_run_api', 10 , 1);  function add_item_meta_or_run_api( $  order_id ) {  $  order = wc_get_order( $  order_id );   if (wcs_order_contains_subscription( $  order, 'renewal' )){ //check if the order contains a renewal subscription    foreach ($  order->get_items() as $  item_id => $  item_obj) { //loop through each rewnewal item        $  parent_id = $  item_obj->get_parent_id(); // Get the parent order ID for the subscriptions.       $  parentSubscriptions = wcs_get_subscriptions_for_order( $  parent_id );//get parent order subscriptions                 foreach (  $  parentSubscriptions->get_items() as $  parent_item_id => $  subscription_item_obj) { //loop through parent order items and get the meta.                   $  ParentCallinData = $  subscription_item_obj->get_meta('call_in_data');               // Store parenent item call in data in renewal order item meta         wc_update_order_item_meta($  item_id,'call_in_data',   $  ParentCallinData, true);             }    } }   else {//if there is not a subscription renewal in the order then we run the Api       foreach ($  order->get_items() as $  item_id => $  item_obj) {    //Code here has been removed that builds and runs the API call to dynamically get the call-in data and store it in $  APIresponse          wc_update_order_item_meta($  item_id,'call_in_data',  $  APIresponse, true); //the APIresponse is added to an order item meta key     }    }   } 

Problem with displaying CSS Stylesheets – Am I adding them correctly in my wordpress child theme?

Is this a proper way to load CSS files into my WordPress child theme?

add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' ); add_action( 'wp_enqueue_scripts', 'case_studies_styles' ); add_action( 'wp_enqueue_scripts', 'about_styles' );  function my_theme_enqueue_styles() {     wp_enqueue_style( 'child-style', get_stylesheet_uri(),         array( 'parenthandle' ),          wp_get_theme()->get('Version') // this only works if you have Version in the style header     ); }  function case_studies_styles() {     wp_enqueue_style( 'child-casestudies', get_stylesheet_directory_uri() . '/casestudies.css', array(), rand()); }  function about_styles() {     wp_enqueue_style( 'child-about', get_stylesheet_directory_uri() . '/about.css', array(), rand()); } 

I’m asking because I’ve asked some people to try to load my site, and some of them don’t get the stylesheets at all and just get the blank HTML code.

Also, in the beginning of all CSS files, I have this beginning. Every CSS file has a different version (1.2,1.1,1.0)

/*  Theme Name:   GeneratePress Child  Theme URI:    https://generatepress.com  Description:  Default GeneratePress child theme  Template:     generatepress  Version:      1.2 */ 

wp_remove_object_terms correct way to call child of parent taxonomy in woocommerce

In Woocommerce I am currently able to assigned and unassign a product taxonomy from a product by calling the following.

// to assign wp_add_object_terms ( $  product_id,'in-stock', 'product_cat' );  //to unassign wp_remove_object_terms ( $  product_id,'in-stock', 'product_cat' );  

However how would one achieve this with a child of the parent taxonomy.

Do I need to call the parent and then the childs tag_ID ? Maybe something like below. Can someone clarify how I should correctly format ‘pa_stock&tag_ID=27’ please.

wp_remove_object_terms ( $  product_id,'in-stock', 'pa_stock&tag_ID=27' );  

Just to clarify pa_stock represents the parent taxonomy, tag_ID 27 represents the child taxonomy.

Is there any lore that explains why the feral child is human only

So I was thinking of making a druid a skimmed through the archetypes to see if there was anything good, under racial archetypes saw the Feral Child it was listed as only human for some reason. I showed my dm the flavor text and he also found it odd. That made me curious so I came here to ask.

The flavor text reads as follows

The feral child is an archetype of the druid class, available to human druids.

Some youths, abandoned in the wilderness and then raised by animals, are so connected with their adoptive home and family that they become feral. Suspicious of civilized society, these foundlings often choose allegiance to the wild over their human forebears.

Although it specifically calls for humans I find it hard to believe that humans are the only race who throw unwanted children into the wilderness. Is there anything I’m missing that makes it so that only humans can have this class?

With all that in mind, I ask the question: why are humans the only race that can access feral child. Since we obviously can’t know what the devs were thinking it would probably be more effective to look for lore so let’s go with that.

Next Previous siblings child pages

I tried this piece of code : https://wordpress.stackexchange.com/a/54474/80921 because I couldn’t figure out how to get the next and the previous post. But this code won’t work now and I’m not able to comment.

The error I get is "Undefined offset: -1" when looking for the ID. Here is the full code found on the related page. Thanks for any help !

$  pagelist = get_pages("child_of=".$  post->post_parent."&parent=".$  post->post_parent."&sort_column=menu_order&sort_order=asc"); $  pages = array(); foreach ($  pagelist as $  page) {    $  pages[] += $  page->ID; }  $  current = array_search($  post->ID, $  pages); $  prevID = $  pages[$  current-1]; $  nextID = $  pages[$  current+1]; ?>  <div class="navigation"> <?php if (!empty($  prevID)) { ?> <div class="previous"> <a href="<?php echo get_permalink($  prevID); ?>" title="<?php echo get_the_title($  prevID); ?>">Previous</a>  </div> <?php } if (!empty($  nextID)) { ?> <div class="Next"> <a href="<?php echo get_permalink($  nextID); ?>" title="<?php echo get_the_title($  nextID); ?>">Next</a> </div> <?php } ?> </div>