Example #1
0
function obtenerHijos($idPadre, $numPages)
{
    $hijos = array();
    $elpost = array();
    $args = array('post_type' => 'page', 'posts_per_page' => $numPages, 'post_parent' => $idPadre, 'order' => 'ASC', 'orderby' => 'menu_order');
    $parent = new WP_Query($args);
    if ($parent->have_posts()) {
        while ($parent->have_posts()) {
            $parent->the_post();
            $elpost = array("ID_Hijo" => get_post()->ID, "Meta_array" => get_post_meta_all(get_post()->ID));
            array_push($hijos, $elpost);
        }
    }
    wp_reset_query();
    return $hijos;
}
Example #2
0
function insert_metas_in_head()
{
    global $post, $language;
    $max_text_description = 200;
    $max_inc_loop = 15;
    $title = null;
    $text = null;
    $site_name = 'Chorum';
    $type = 'article';
    // 1. On récupère le magazine le plus récent publié
    $url_site = 'http://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
    if ($post->post_type === 'produits') {
        global $postMetas;
        if (!isset($postMetas)) {
            $postMetas = get_post_meta_all($post->ID);
        }
        $uri = $_SERVER['REQUEST_URI'];
        $title = $postMetas['ref_produit'] . ' - ' . $postMetas['nom_produit'];
        if (!$url_img) {
            $url_img = affiche_visuel($postMetas['ref_produit'], 1);
        }
        $imgInfos = @getimagesize($url_img);
        $text = $postMetas['description'];
    } elseif (is_front_page()) {
        $title = "Chorum";
        $text = "Chorum";
        $url_img = "";
        $imgInfos = @getimagesize($url_img);
    } else {
        $title = "Chorum";
        $text = "Chorum";
    }
    if ($title && $text) {
        echo '<meta property="og:title" content="' . esc_attr($title) . '"/>' . "\n";
        echo '<meta property="og:description" content="' . esc_attr($text) . '"/>' . "\n";
        echo '<meta property="og:type" content="' . $type . '"/>' . "\n";
        echo '<meta property="og:url" content="' . $url_site . '"/>' . "\n";
        echo '<meta property="og:site_name" content="' . $site_name . '"/>' . "\n";
        echo '<meta property="og:image" content="' . $url_img . '"/>' . "\n";
        echo '<meta property="og:image:type" content="' . $imgInfos["mime"] . '"/>' . "\n";
        if (!empty($imgInfos)) {
            echo '<meta property="og:image:width" content="' . $imgInfos[0] . '"/>' . "\n";
            echo '<meta property="og:image:height" content="' . $imgInfos[1] . '"/>' . "\n";
        }
        //$text_SEO = substr($text, 0, $coupe); desactivé pour l'instant
        echo '<meta name="description" content="' . esc_attr($text) . '"/>' . "\n";
        echo '<meta name="twitter:card" content="summary_large_image"/>' . "\n";
        echo '<meta name="twitter:site" content="@ChorumFrance"/>' . "\n";
        echo '<meta name="twitter:title" content="' . esc_attr($title) . '"/>' . "\n";
        echo '<meta name="twitter:description" content="' . esc_attr($text) . '"/>' . "\n";
        echo '<meta name="twitter:image" content="' . $url_img . '"/>' . "\n";
    }
}