miya0001 / child-pages-shortcode

17 stars 11 forks source link

Compatibility issue with qtranslate (translation plugin) #5

Open ghost opened 11 years ago

ghost commented 11 years ago

Hi!

I'm using qtranslate and child-page-shortcode on a wordpress blog. If you try to use the child pages shortcode with pages which are already translated you will see all languages at the same time.

This fix works for me:

foreach ($pages as $post) {
    setup_postdata($post);
    $post = apply_filters('child_pages_shortcode_post', $post);
    $url = get_permalink($post->ID);
    $img = get_the_post_thumbnail($post->ID, $p['size']);
    $img = preg_replace( '/(width|height)="\d*"\s/', "", $img);
    $tpl = $template;
    $tpl = str_replace('%width%', esc_attr($p['width']), $tpl);
    $tpl = str_replace('%post_id%', intval($post->ID), $tpl);
    // FIX
    if (isset($p['disabled_excerpt_filters']) && $p['disabled_excerpt_filters']) {
        $tpl = str_replace('%post_title%', $post->post_title, $tpl);
    } else {
        $tpl = str_replace('%post_title%', apply_filters('the_title', $post->post_title), $tpl);
    }
    // END FIX
    $tpl = str_replace('%post_url%', esc_url($url), $tpl);
    $tpl = str_replace('%post_thumb%', $img, $tpl);
    // FIX
    if (isset($p['disabled_excerpt_filters']) && $p['disabled_excerpt_filters']) {
        $tpl = str_replace('%post_excerpt%', $post->post_excerpt, $tpl);
    } else {
        $tpl = str_replace('%post_excerpt%', apply_filters('the_excerpt', $post->post_excerpt), $tpl);
    }
    // END FIX
    $html .= $tpl;
}
ummiq commented 10 years ago

Hi!

Where did you put this code?