Created
August 6, 2020 11:50
-
-
Save davidchc/c13429881035e5fb2d85a22eee7294c3 to your computer and use it in GitHub Desktop.
Retorna em string os slugs
This file contains 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 characters
<?php | |
//Cria uma função pra retornar os slugs da taxonomia de um post | |
function getSlugsTaxonomy($post_id) { | |
$terms = wp_get_post_terms( $post_id, 'nome_da_sua_taxonomia', array( 'fields' => 'all' ) ); | |
$results = array(); | |
foreach($terms as $term) { | |
$results[] = $term->slug; | |
} | |
return $results ? implode(' ', $results) : ''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment