• Hi Wayne,

    I found your sliding door theme interesting, but wondering, why not using post thumbnails as sliding images, which could be uploaded and edited simply in the WP-mediathek.
    There has to be made only some small changes in the function.php and the header.php.

    In header.php change
    <?php slider_menuparse(wp_list_pages(‘sort_column=ID&depth=1&number=7&title_li=&echo=0’)); ?>
    to
    <?php slider_menuparse(get_pages(‘sort_column=menu_order&child_of=0&parent=0&hierarchical=0&number=7’)); ?>
    (btw: For me it was better to sort the pages acc. to the menu_order)

    In function.php add at the beginning
    <?php if ( function_exists( ‘add_theme_support’ ) ) {
    add_theme_support( ‘post-thumbnails’ );
    }
    ?>
    to initialise post thumbs in the theme.

    In function.php change the function slider_menuparse() to

    function slider_menuparse($pages){
    $output = “”;
    foreach ($pages as $page){
    $thumbnail_url = wp_get_attachment_image_src(get_post_thumbnail_id($page->ID), ‘full’);
    $output .= ‘<li class=”page-item page-item-‘ . $page->ID .'”>ID) . ‘” title=”‘ . $page->post_title . ‘” style=”background: url(‘ . $thumbnail_url[0] . ‘) no-repeat;”>’ . $page->post_title . ‘‘;
    }
    echo $output;
    }

    Greetings
    Bernhard

Viewing 4 replies - 1 through 4 (of 4 total)
  • Theme Author wayneconnor

    (@wayneconnor)

    Yep thanks,
    I’ve upgraded it to use featured image. It was not as simple as you suggested, lots of custom code needed, that’s why it’s taken a while.
    Wayne

    Thread Starter bhenselmann

    (@bhenselmann)

    Fine! I′ll try it out. In the meantime I made some additional changes to the code to use more or less than 7 pages in the sliding menu with calculating the width of the sliders. And I′m thinking on including a custom field to tell the theme which page has to be used in the sliding menu and which not.
    If you′re interested I′ll send the code.
    Greetings
    Bernhard

    Theme Author wayneconnor

    (@wayneconnor)

    Sound great Bernhard – I’d love to see the adjustable width code and might incorporate it in.

    Wayne

    Thread Starter bhenselmann

    (@bhenselmann)

    OK – this is the modified code I′m using for the adjustable width (but not with the mentioned costum field, which is not ready yet) :

    [please use the ‘code’ button to mark the code; also, in future, please use the pastebin when posting code longer than 10 lines.]

    function slider_menuparse($pages, $postID){
    $output = “”;
    $count = count($pages);
    $menuwidth = 133*7; /* the imageMenu-width in px */
    if (get_post_type( $postID ) == ‘post’) $postID=get_option(‘page_for_posts’); /* this is to include the css-class current_page_item when a page for posts is defined in WP options */
    foreach ($pages as $page){
    $cp = “”; /* for css-class of current_page_item */
    $thumbnail_url = wp_get_attachment_image_src(get_post_thumbnail_id($page->ID), ‘full’);
    if ($page->ID == $postID) $cp= ” current_page_item “;
    $output .= ‘<li class=”page-item page-item-‘ . $page->ID . $cp . ‘”>ID) . ‘” title=”‘ . htmlentities($page->post_title) . ‘” style=”background: url(‘ . $thumbnail_url[0] . ‘) no-repeat; width:’ . $menuwidth/$count . ‘px;”>’ . $page->post_title . ‘‘;
    }
    echo $output;
    }

    I used tis in the websites
    https://www.art-room9.de/
    and
    https://www.art-gegenwart.com/
    but maybe you have to adjust it?
    Greetings
    Bernhard

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘sliding door with post thumbnail’ is closed to new replies.