How can i change sort category view starting from child then parent, not alphabetically

I have created categories by city and districts.

On the archive page, it displays well.

The problem is, the views are sorted alphabetically.

As a example :

City (Jakarta)

Districts 1 (Tebet) Districts 2 (Cilandak) Districts 3 (Gambir)

Now displaying :

Cilandak Jakarta

Gambir Jakarta

Jakarta Tebet

I want :

Cilandak Jakarta

Gambir Jakarta

Tebet Jakarta

can anyone give me some help how to change it?

Sorry if my English is bad. thank you

I’ve created a snippet like this:

add_action('woocommerce_loop_add_to_cart_link','displaying_product_attributes',5); 

function displaying_product_attributes () { global $ product;

$  harga_val = $  product->get_attribute('pa_harga');  $  kt_val = $  product->get_attribute('pa_kt'); $  km_val = $  product->get_attribute('pa_km');  $  luas_bangunan_val = $  product->get_attribute('pa_luas-bangunan'); $  luas_tanah_val = $  product->get_attribute('pa_luas-tanah');        

$ terms = get_the_terms( $ product->get_id(),’product_cat’ ); if( $ terms ) { $ names = array(); foreach ( $ terms as $ term ) { $ names[] = $ term->name;

} 

}

echo "<p style='color:#1ebf41; text-align:left; text-indent: 3px; font-size:18px;line-height: 0.5; font-weight:bold'>".$  harga_val."</p>";   echo "<p style='color:#333; text-align:left; text-indent: 3px; font-size:14px;line-height: 0.1;'><i class='fas fa-bed'></i> &nbsp;".$  kt_val."&emsp;<i class='fas fa-shower'></i> &nbsp;".$  km_val."&emsp;<i class='fa fa-home'></i>&nbsp; ".$  luas_bangunan_val."m<sup>2</sup>&emsp;<i class='fas fa-expand-arrows-alt'></i>&nbsp; ".$  luas_tanah_val."m<sup>2</sup></p>";   print '<p style="color:#333; text-align:left; text-indent: 3px; font-size:14px;line-height: 1;"><i class="fas fa-map-marker-alt"></i> &nbsp; '.join( ', ', $  names ).'</p>'.PHP_EOL;; 

}

Where to use Post class in a real theme, title, content or parent div or article tag?

I am extending discussion from one another article posted on the same website → Where should I use post_class()?.

This is the portion from content-single.php

enter image description here

Where should I put the post-class? in the h2 tag that will print the title or on the parent article tag, which has one other div,which is a sibling to h2, title class?

  <h4><?php the_title(); ?></h4>   <p><?php the_content(); ?></p> 

I browsed this link, but still, I could not get the clarity → https://developer.wordpress.org/reference/functions/post_class/

REQUIRED: Could not find post_class. See: post_class <div id="post-" >

remove SLASH on single_post but KEEP on categories and parent pages

My current permalink structure is  /%category%/%postname%/  which produce urls as:
(category_base removed using "FV Top Level Categories" Plugin)

category: example.com/class-10/science/    ◀▬ SLASH is GOOD for directories & ↙ parent pages     page: example.com/legal/      post: example.com/class-10/science/ch-1-atoms/    ◀▬ but BAD for single_post, ↖ child pages &     page: example.com/legal/terms/     page: example.com/about/    ◀▬ standalone pages 

So, I want to
keep TRAILING SLASH "/" on:

  • categories and child categories
  • parent pages

remove TRAILING SLASH "/" on:

  • single_posts
  • standalone page (who don’t have any child pages)
  • child pages

AND "301" Redirect  "/"  version of these ↖ pages to NON  "/"  version pages

How to limit PostgreSQL INSERTs to assure that the caller has an attribute conistent with the parent table?

In the parent table, there is a column that defines the ‘owner’ of the row. When inserting into the child, the caller provides an owner id or ‘%’, to indicate that the the caller is the administrator. I was expecting the insert with this check to be slower that a straight insert, but I didn’t expect a 70x penalty. Can you give me some ideas for how to optimize the performance to achieve the same result as this statement?

INSERT INTO child (parent_key, value1, value2)   SELECT $  1, $  2, $  3 FROM parent      WHERE parent_key = $  1       AND owner LIKE $  4     LIMIT 1; 

Table definitions:

CREATE TABLE parent (   parent_key VARCHAR(255) PRIMARY KEY,    owner VARCHAR(255) );  CREATE TABLE child (   child_key SERIAL PRIMARY KEY,    parent_key VARCHAR(255) REFERENCES parent,    value1 VARCHAR(255),    value2 VARCHAR(255) ); 

I ran an explain on my statement, and this is what I see.

 Insert on child  (cost=0.42..8.46 rows=1 width=1670)    ->  Subquery Scan on "*SELECT*"  (cost=0.42..8.46 rows=1 width=1670)          ->  Limit  (cost=0.42..8.44 rows=1 width=296)                ->  Index Scan using parent_pkey on parent  (cost=0.42..8.44 rows=1 width=296)                      Index Cond: ((parent_key)::text = '111'::text)                      Filter: ((owner)::text ~~ '%'::text) 

Since parent_pkey is a unique index, I would expect the LIKE filter to contribute an insignificant amount to the execution time. This conditional INSERT takes >70 times as long as an INSERT of VALUES. What would be a more efficient way of enforcing this constraint?

display childs without parent

The following code displays the parent plus his children on the specific parent- and children-category pages as "filter-buttons". But in this list I do not want to display the parent, (because the parent is already displayed as "ALL"). How can I display list with only the childre/ without the parent?

Thank you for any further help.

<?php $ categories = get_the_category(); foreach($ categories as $ key => $ category) { $ url = get_term_link((int)$ category->term_id,'category'); $ categories[$ key] = "<pre><a href=\"{$ url}\">{$ category->name}</a></pre>"; } echo "" . implode("\n",$ categories) . ""; ?>

Unity2D – Rotation of gun following mouse error when parent ‘player’ object rotates

I have a bug I’ve been trying to fix with the rotation of a gun object that follows the mouse position but has issues when the parent object player rotates. Example:

Example of rotation error

The player has a gravity script to keep them aligned with the ‘planet’ as you walk around it. The gun as a child of the player, is supposed to always rotate to point at where the mouse is (sorry you can’t see it in the gif). The gun normally flips itself at 90 and -90 (top and bottom), and flips the player to face the same side the mouse is on.

The problem is that the player rotates to stay aligned with the planet, but the 90 and -90 angles that the gun bases flipping itself and the player off of course don’t rotate.

Here’s my code for the gun:

         Vector3 difference = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;           difference.Normalize();           float rotationZ = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;            float startRotation = rotationZ + offset;            float shotRotation = startRotation + Random.Range(-scatter, scatter);            transform.rotation = Quaternion.Euler(0f, 0f, startRotation);            //Flip the gun at top and bottom           if (rotationZ < -90 || rotationZ > 90)           {               if (player.transform.eulerAngles.y == 0)               {                   transform.localRotation = Quaternion.Euler(180, 0, -rotationZ + offset);               }               else if (player.transform.eulerAngles.y == 180)               {                   transform.localRotation = Quaternion.Euler(180, 180, -rotationZ + offset);               }           }            //Use gun rotation to set player direction           //left           if (rotationZ >= -90f || rotationZ <= 90f)           {               animator.SetFloat("Vertical", 0);               animator.SetFloat("Horizontal", -1);           }           //right           if (rotationZ <= -90f || rotationZ >= 90f)           {               animator.SetFloat("Vertical", 0);               animator.SetFloat("Horizontal", 1);           }

DreamHost error when trying to add a domain: “You can’t add that domain: you must add the parent domain”

I have hosting account on DreamHost I want to add my domain (which is registered outside Dreamhost) I have already changed nameservers. my domain is "xxxx.edu.eg" but I have the following problem: "You can’t add that domain: you must add the parent domain edu.eg to your account before adding a subdomain to it." How to solve it and thank you in advance

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     }    }   } 

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.

Get parent theme version

How do I get the parent theme’s version in a child theme?

I want to use it when loading the parent theme’s stylesheet.

Here’s how I load the stylesheets in the child theme’s function.php file:

function sometheme_enqueue_styles() {    // Get parent theme version   $  parent_theme_version = wp_get_theme()->parent()->get( 'Version' );    // Load parent theme stylesheet   wp_enqueue_style( 'sometheme-style', get_template_directory_uri() . '/style.css', array(), $  parent_theme_version );    // Load child theme stylesheet   wp_enqueue_style( 'sometheme-child-style',     get_stylesheet_directory_uri() . '/style.css',     array( 'sometheme-style' ),     wp_get_theme()->get('Version')   );  } add_action( 'wp_enqueue_scripts', 'sometheme_enqueue_styles', 11 ); 

However, this will use the child theme’s version for both stylesheets…

I have also tried this:

$  parent_theme = wp_get_theme('sometheme'); $  parent_theme_version = $  parent_theme->get( 'Version' ); 

…and this:

$  parent_theme = wp_get_theme(get_template()); $  parent_theme_version = $  parent_theme->get( 'Version' ); 

But again, the parent theme version keeps getting the version from the child theme.