[Resolved] Let a page automatically adopt the featured image of it's first child

Home Forums Support [Resolved] Let a page automatically adopt the featured image of it's first child

Home Forums Support Let a page automatically adopt the featured image of it's first child

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #810781
    Florian

    I use the following custom post type to redirect certain pages to their first child page. Is it possible to add something so it also adopts the child page’s thumbnail? Preferably in a way that it also automatically updates if I ever change it.

    <?php
    /*
    Template Name: Go to first child
    */
    $pagekids = get_pages("child_of=".$post->ID."&sort_column=menu_order");
    if ($pagekids) {
    $firstchild = $pagekids[0];
    wp_redirect(get_permalink($firstchild->ID));
    } else {
    // Do whatever templating you want as a fall-back.
    }
    ?>
    #810853
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Looks like that code redirects you to the child page automatically. Wouldn’t that child page already have the featured image set?

    #811115
    Florian

    Yes, but I need the parent to have the same featured image as part 1 because the parent page gets displayed in the sidebar together with its thumbnail.

    #811435
    Tom
    Lead Developer
    Lead Developer

    How are you displaying the parent page in the sidebar?

    #811448
    Florian

    A plugin displays a random subset of child pages of /tutorials/android
    Sometimes these child pages contain single videos -> the thumbnail is displayed
    But sometimes these child pages contain their own child pages (because it’s a video series with multiple parts), in which case the parent doesn’t have a thumbnail on its own.

    #811660
    Tom
    Lead Developer
    Lead Developer

    It would likely need to be an option inside the plugin then, unfortunately. You can check with the developer if such a thing is possible.

    #811848
    Florian

    So a page can not adopt the thumbnail of another page? I really thought that would be possible.

    #812210
    Tom
    Lead Developer
    Lead Developer

    It can, but it needs to be coded into the output. If you’re using a plugin to output the post, the code needs to be inserted into the plugin, or there needs to be a filter available. That’s where the plugin author should hopefully be able to help.

    #812212
    Florian

    Ok thanks, I will contact the plugin author then!

    #812405
    Tom
    Lead Developer
    Lead Developer

    No problem 🙂

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.