Last active
March 20, 2021 10:50
-
-
Save pixeldevsio/11b3f80e322eb0f10fdf1d6c9ce97d32 to your computer and use it in GitHub Desktop.
Revisions
-
pixeldevsio revised this gist
Mar 20, 2021 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,10 @@ function pd_get_term_children($slug, $term_type = 'category'){ // set up category by slug $category = get_term_by('slug', "{$slug}", "{$term_type}"); // get out if no category if(!$category){return;} $cat_id = $category->term_id; //get the children as an array -
pixeldevsio revised this gist
Mar 20, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ function pd_get_term_children($slug, $term_type = 'category'){ $cat_id = $category->term_id; //get the children as an array $cat_children = get_term_children( $cat_id, "{$term_type}"); // call a display function to show the children return pd_display_term_children($cat_children, $term_type); -
pixeldevsio revised this gist
Mar 20, 2021 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,12 +10,12 @@ function pd_get_term_children($slug, $term_type = 'category'){ $cat_children = get_term_children( $cat_id, 'category'); // call a display function to show the children return pd_display_term_children($cat_children, $term_type); } // helper function to display term children function pd_display_term_children($cat_children, $term_type){ echo '<ul>'; foreach ( $cat_children as $child ) { $term = get_term_by( 'id', $child, $term_type ); -
pixeldevsio revised this gist
Mar 20, 2021 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ <?php // helper function to get term children function pd_get_term_children($slug, $term_type = 'category'){ // set up category by slug $category = get_term_by('slug', "{$slug}", "{$term_type}"); @@ -25,4 +25,4 @@ function pd_display_cat_children($cat_children, $term_type){ } //use case example pd_get_term_children('parentcat', 'category'); -
pixeldevsio revised this gist
Mar 20, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,4 +25,4 @@ function pd_display_cat_children($cat_children, $term_type){ } //use case example pd_get_cat_children('parentcat', 'category'); -
pixeldevsio revised this gist
Mar 20, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,7 @@ function pd_get_cat_children($slug, $term_type = 'category'){ // helper function to display term children function pd_display_cat_children($cat_children, $term_type){ echo '<ul>'; foreach ( $cat_children as $child ) { $term = get_term_by( 'id', $child, $term_type ); echo '<li><a href="' . get_term_link( $child, $taxonomy_name ) . '">' . $term->name . '</a></li>'; -
pixeldevsio renamed this gist
Mar 20, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
pixeldevsio revised this gist
Mar 20, 2021 . No changes.There are no files selected for viewing
-
pixeldevsio revised this gist
Mar 20, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,4 +25,4 @@ function pd_display_cat_children($cat_children, $term_type){ } //use case example echo pd_get_cat_children('parentcat', 'category'); -
pixeldevsio created this gist
Mar 20, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ <?php // helper function to get children function pd_get_cat_children($slug, $term_type = 'category'){ // set up category by slug $category = get_term_by('slug', "{$slug}", "{$term_type}"); $cat_id = $category->term_id; //get the children as an array $cat_children = get_term_children( $cat_id, 'category'); // call a display function to show the children return pd_display_cat_children($cat_children, $term_type); } // helper function to display term children function pd_display_cat_children($cat_children, $term_type){ echo '<ul style="background: green">'; foreach ( $cat_children as $child ) { $term = get_term_by( 'id', $child, $term_type ); echo '<li><a href="' . get_term_link( $child, $taxonomy_name ) . '">' . $term->name . '</a></li>'; } echo '</ul>'; } //use case example echo pd_get_cat_children('parentcat');