first draft of thumbnail updater according to thematique picture
This commit is contained in:
parent
2978c43bb7
commit
a340310323
|
|
@ -6,6 +6,7 @@ require_once(__DIR__ . '/includes/init.php');
|
|||
require_once(__DIR__ . '/includes/blocks.php');
|
||||
require_once(__DIR__ . '/includes/post_types.php');
|
||||
require_once(__DIR__ . '/includes/post-brochures.php');
|
||||
require_once(__DIR__ . '/includes/post-conseils.php');
|
||||
require_once(__DIR__ . '/includes/admin.php');
|
||||
require_once(__DIR__ . '/includes/logos.php');
|
||||
require_once(__DIR__ . '/includes/taxonomy.php');
|
||||
|
|
|
|||
27
includes/post-conseils.php
Normal file
27
includes/post-conseils.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
// Function to update features image of posts depending on its type , to get used for og:image
|
||||
// Currently commented because not working with the current svg version of thematiques pictures
|
||||
|
||||
// add_action('save_post', 'flex_FeaturedImageSetByACF');
|
||||
function flex_FeaturedImageSetByACF()
|
||||
{
|
||||
global $post;
|
||||
if (!$post) return;
|
||||
|
||||
if ($post->post_type === 'conseils') {
|
||||
$currentThematique = get_the_terms($post->ID, 'thematiques') ? get_the_terms($post->ID, 'thematiques')[0] : null;
|
||||
$mainThematique = getMainThematique($currentThematique) ?? null;
|
||||
if (!$mainThematique) return;
|
||||
|
||||
$mainThematiqueFr = apply_filters('wpml_object_id', $mainThematique->term_id, 'thematiques', TRUE, 'fr');
|
||||
$thematique_picture = get_field('taxonomy_pictures', "thematiques_" . $mainThematiqueFr)['illustration_s'] ?? null;
|
||||
if (!$thematique_picture) return;
|
||||
|
||||
add_post_meta($post->ID, '_thumbnail_id', $thematique_picture['ID']);
|
||||
};
|
||||
|
||||
if ($post->post_type === 'page') {
|
||||
write_log("un page mon ami");
|
||||
};
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user