homegrade_theme_production/includes/utilities.php
2023-08-03 10:31:09 +02:00

53 lines
1.0 KiB
PHP

<?php
function getThematiqueFamilySlug($thematique_slug)
{
switch ($thematique_slug) {
case "energie":
case "urbanisme":
return "energies-urbanisme";
case "acoustique":
case "petites-coproprietes":
return "acoustique-coproprietes";
case "isolation":
case "au-quotidien":
return "isolation-quotidien";
case "energies":
case "urbanisme":
return "energies-urbanisme";
case "patrimoine":
case "renovation":
return "patrimoine-renovation";
case "location":
return "location";
}
}
function getParentThematique($thematique)
{
if($thematique->parent == 0) {
return $thematique;
} else {
return get_term($thematique->parent, 'thematiques');
}
}
// Get automatic post used in BLOCK QUESTIONS FREQUENTES
function get_automatic_post($post_type)
{
$automatic_query_args = array(
'numberposts' => 2,
'post_per_page' => 1,
'post_status' => 'publish',
'post_type' => 'fiche-questions',
'thematiques' => $post_type,
);
return get_posts($automatic_query_args)[0];
}