Hallo,
dies ist meine erste Frage in diesem Forum. Ich bin Anfänger und habe mir deshalb das theme twentyeleven rausgesucht. Habe nun aber schon erste Schwierigkeiten. Habe eine statische Startseite und dort über das Plugin SP Responsive header slider einen slider eingebaut, der auch funktioniert (habe code in die header.php eingesetzt und einen Zusatz, dass der slider nur auf der Startseite erscheint).
Nun möchte ich auf den anderen Seiten normale Headerbilder über Beitragsbild einsetzen, dass funktioniert aber einfach nicht. Unter Optionen habe ich Beitragsbild angeklickt.
Wenn ich übrigens unter Design-Anpassen-Headerbild, ein Bild hochlade erscheint es auf der Startseite über dem Slider und auf den Seiten erscheinen die Beitragsbilder....???..merkwürdig, oder?
Was ist die Lösung? :?::?::?::?:
Gruß
ulli
Beitragsbilder bei twentyeleven erscheinen nicht; Slider auf Starseite installiert
-
-
- Gerade eben
- Anzeige
Hallo!
Wenn du gerade an deiner Website arbeitest oder dein aktuelles Hosting überdenkst: Wir betreiben mit NetzLiving eine Hosting-Plattform, die speziell auf Performance, Sicherheit und einfache Verwaltung ausgelegt ist.
- ✔️ Schnelle Ladezeiten (optimiert für WordPress & Co.)
- ✔️ Deutsche Server & DSGVO-konform
- ✔️ Persönlicher Support (kein 0815-Ticket-System)
-
Das liegt daran, dass im Theme erst nach dem dem header-image gefragt wird und dann erst nach dem Beitragsbild.
PHP
Alles anzeigen<?php // Check to see if the header image has been removed $header_image = get_header_image(); [COLOR="#FF0000"]if ( $header_image ) :[/COLOR] <a href="<?php echo esc_url( home_url( '/' ) ); ?>"> <?php /* * The header image. * Check if this is a post or page, if it has a thumbnail, and if it's a big one */ [COLOR="#FF0000"]if ( is_singular() && has_post_thumbnail( $post->ID )[/COLOR] && ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( $header_image_width, $header_image_width ) ) ) && $image[1] >= $header_image_width ) : // Houston, we have a new header image! echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' ); else : // Compatibility with versions of WordPress prior to 3.4. if ( function_exists( 'get_custom_header' ) ) { $header_image_width = get_custom_header()->width; $header_image_height = get_custom_header()->height; } else { $header_image_width = HEADER_IMAGE_WIDTH; $header_image_height = HEADER_IMAGE_HEIGHT; } ?> <img src="<?php header_image(); ?>" width="<?php echo esc_attr( $header_image_width ); ?>" height="<?php echo esc_attr( $header_image_height ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" /> [COLOR="#FF0000"]<?php endif; // end check for featured image or standard header ?>[/COLOR] </a> [COLOR="#FF0000"]<?php endif; // end check for removed header image ?>[/COLOR]Demnach müsstest du ein bisschen Code umschreiben, so dass der Slider nur für die Startseite abgefragt wird und der Rest für den anderen Content. Ich würde es mal auf die Schnelle so versuchen:
PHP
Alles anzeigen<?php // Check to see if the header image has been removed $header_image = get_header_image(); [COLOR="#FF0000"]if (is_home() || is_front_page()) : Dein SLIDER-Code elseif ( $header_image ) :[/COLOR] ... ...Dann muss allerdings trotzdem noch unter Design-Anpassen-Headerbild, ein Bild hoch geladen sein.
Wie was wo angezeigt wird liegt halt immer am gewählten Theme.
-
Hallo Maxe,
habe folgendes in meiner header.php eingebaut:
<?php endif; // end check for removed header image ?><?php if (is_front_page() ) : ?>
<div class="headerslider"> <?php echo do_shortcode('[sp_responsiveslider limit="-1"]'); ?></div>
<?php endif ?>
Der Slider funktioniert einwandfrei auf der Startseite, doch kann ich in die übrigen Seiten keine Beitragsbilder festlegen.
Sollte ich diesen Zusatz noch einbauen?: [COLOR=#FF0000]elseif ( $header_image ) :
[/COLOR]Das funktioniert nicht, der code erscheint dann direkt über meinem Slider auf der Seite....habe ich wohl falsch verstanden.
Weiß immer noch nicht, wie ich das Problem mit den Beitragsbildern lösen soll.
Weißt du Rat????
Gruß
Ulli -
ich hatte dir doch oben geschrieben, was du ändern sollst:
PHP
Alles anzeigen<?php // Check to see if the header image has been removed [COLOR="#FF0000"] $header_image = get_header_image(); if (is_home() || is_front_page()) : ?> <div class="headerslider"> <?php echo do_shortcode('[sp_responsiveslider limit="-1"]'); ?></div> <?php elseif ( $header_image ) :[/COLOR] <a href="<?php echo esc_url( home_url( '/' ) ); ?>"> <?php /* * The header image. * Check if this is a post or page, if it has a thumbnail, and if it's a big one */ if ( is_singular() && has_post_thumbnail( $post->ID ) && ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( $header_image_width, $header_image_width ) ) ) && $image[1] >= $header_image_width ) : // Houston, we have a new header image! echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' ); else : // Compatibility with versions of WordPress prior to 3.4. if ( function_exists( 'get_custom_header' ) ) { $header_image_width = get_custom_header()->width; $header_image_height = get_custom_header()->height; } else { $header_image_width = HEADER_IMAGE_WIDTH; $header_image_height = HEADER_IMAGE_HEIGHT; } ?> <img src="<?php header_image(); ?>" width="<?php echo esc_attr( $header_image_width ); ?>" height="<?php echo esc_attr( $header_image_height ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" /> <?php endif; // end check for featured image or standard header ?> </a> <?php endif; // end check for removed header image ?> -
Hallo Maxe,
es klappt einfach nicht!
Das ist meine child header.php mit dem eingebauten Slider.
Wenn ich den an der Stelle wo er jetzt ist rauslösche und deinen Code an die Stelle nach: // Check to see if the header image has been removed, einsetzte, bekomme ich ein Fehlermeldung.
Sorry, wie gesagt, ich bin blutiger Anfänger. Ich hoffe ich nerve nicht zu sehr!PHP
Alles anzeigen<?php /** * Header template for the theme * * Displays all of the <head> section and everything up till <div id="main">. * * @package WordPress * @subpackage Twenty_Eleven * @since Twenty Eleven 1.0 */ ?><!DOCTYPE html> <!--[if IE 6]> <html id="ie6" <?php language_attributes(); ?>> <![endif]--> <!--[if IE 7]> <html id="ie7" <?php language_attributes(); ?>> <![endif]--> <!--[if IE 8]> <html id="ie8" <?php language_attributes(); ?>> <![endif]--> <!--[if !(IE 6) & !(IE 7) & !(IE 8)]><!--> <html <?php language_attributes(); ?>> <!--<![endif]--> <head> <meta charset="<?php bloginfo( 'charset' ); ?>" /> <meta name="viewport" content="width=device-width" /> <title><?php // Print the <title> tag based on what is being viewed. global $page, $paged; wp_title( '|', true, 'right' ); // Add the blog name. bloginfo( 'name' ); // Add the blog description for the home/front page. $site_description = get_bloginfo( 'description', 'display' ); if ( $site_description && ( is_home() || is_front_page() ) ) echo " | $site_description"; // Add a page number if necessary: if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) echo ' | ' . sprintf( __( 'Page %s', 'twentyeleven' ), max( $paged, $page ) ); ?></title> <link rel="profile" href="http://gmpg.org/xfn/11" /> <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" /> <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" /> <!--[if lt IE 9]> <script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script> <![endif]--> <?php /* * We add some JavaScript to pages with the comment form * to support sites with threaded comments (when in use). */ if ( is_singular() && get_option( 'thread_comments' ) ) wp_enqueue_script( 'comment-reply' ); /* * Always have wp_head() just before the closing </head> * tag of your theme, or you will break many plugins, which * generally use this hook to add elements to <head> such * as styles, scripts, and meta tags. */ wp_head(); ?> </head> <body <?php body_class(); ?>> <div id="page" class="hfeed"> <header id="branding" role="banner"> <hgroup> <h1 id="site-title"><span><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></span></h1> <h2 id="site-description"><?php bloginfo( 'description' ); ?></h2> </hgroup> <?php // Check to see if the header image has been removed $header_image = get_header_image(); if ( $header_image ) : // Compatibility with versions of WordPress prior to 3.4. if ( function_exists( 'get_custom_header' ) ) { /* * We need to figure out what the minimum width should be for our featured image. * This result would be the suggested width if the theme were to implement flexible widths. */ $header_image_width = get_theme_support( 'custom-header', 'width' ); } else { $header_image_width = HEADER_IMAGE_WIDTH; } ?> <a href="<?php echo esc_url( home_url( '/' ) ); ?>"> <?php /* * The header image. * Check if this is a post or page, if it has a thumbnail, and if it's a big one */ if ( is_singular() && has_post_thumbnail( $post->ID ) && ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( $header_image_width, $header_image_width ) ) ) && $image[1] >= $header_image_width ) : // Houston, we have a new header image! echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' ); else : // Compatibility with versions of WordPress prior to 3.4. if ( function_exists( 'get_custom_header' ) ) { $header_image_width = get_custom_header()->width; $header_image_height = get_custom_header()->height; } else { $header_image_width = HEADER_IMAGE_WIDTH; $header_image_height = HEADER_IMAGE_HEIGHT; } ?> <img src="<?php header_image(); ?>" width="<?php echo $header_image_width; ?>" height="<?php echo $header_image_height; ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" /> <?php endif; // end check for featured image or standard header ?> </a> <?php endif; // end check for removed header image ?> <?php if (is_front_page() ) : ?> <div class="headerslider"> <?php echo do_shortcode('[sp_responsiveslider limit="-1"]'); ?></div> elseif ( $header_image ) : <?php endif ?> <nav id="access" role="navigation"> <h3 class="assistive-text"><?php _e( 'Main menu', 'twentyeleven' ); ?></h3> <?php /* Allow screen readers / text browsers to skip the navigation menu and get right to the good stuff. */ ?> <div class="skip-link"><a class="assistive-text" href="#content"><?php _e( 'Skip to primary content', 'twentyeleven' ); ?></a></div> <?php if ( ! is_singular() ) : ?> <div class="skip-link"><a class="assistive-text" href="#secondary"><?php _e( 'Skip to secondary content', 'twentyeleven' ); ?></a></div> <?php endif; ?> <?php /* Our navigation menu. If one isn't filled out, wp_nav_menu falls back to wp_page_menu. The menu assigned to the primary location is the one used. If one isn't assigned, the menu with the lowest ID is used. */ ?> <?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?> </nav><!-- #access --> </header><!-- #branding --> <div id="main"> -
ich glaube, ich hatte noch eine ältere header.php vom Theme. Du hast z.B. einige PHP-Tags nicht geöffnet/geschlossen. Außerdem saß der Code an der falschen Stelle.
Hier noch mal die komplett geänderte header.php
PHP
Alles anzeigen<?php /** * Header template for the theme * * Displays all of the <head> section and everything up till <div id="main">. * * @package WordPress * @subpackage Twenty_Eleven * @since Twenty Eleven 1.0 */ ?><!DOCTYPE html> <!--[if IE 6]> <html id="ie6" <?php language_attributes(); ?>> <![endif]--> <!--[if IE 7]> <html id="ie7" <?php language_attributes(); ?>> <![endif]--> <!--[if IE 8]> <html id="ie8" <?php language_attributes(); ?>> <![endif]--> <!--[if !(IE 6) & !(IE 7) & !(IE ]><!--> <html <?php language_attributes(); ?>> <!--<![endif]--> <head> <meta charset="<?php bloginfo( 'charset' ); ?>" /> <meta name="viewport" content="width=device-width" /> <title><?php // Print the <title> tag based on what is being viewed. global $page, $paged; wp_title( '|', true, 'right' ); // Add the blog name. bloginfo( 'name' ); // Add the blog description for the home/front page. $site_description = get_bloginfo( 'description', 'display' ); if ( $site_description && ( is_home() || is_front_page() ) ) echo " | $site_description"; // Add a page number if necessary: if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) echo ' | ' . sprintf( __( 'Page %s', 'twentyeleven' ), max( $paged, $page ) ); ?></title> <link rel="profile" href="http://gmpg.org/xfn/11" /> <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" /> <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" /> <!--[if lt IE 9]> <script src="<?php echo get_template_directory_uri(); ?>/js/html5.js" type="text/javascript"></script> <![endif]--> <?php /* * We add some JavaScript to pages with the comment form * to support sites with threaded comments (when in use). */ if ( is_singular() && get_option( 'thread_comments' ) ) wp_enqueue_script( 'comment-reply' ); /* * Always have wp_head() just before the closing </head> * tag of your theme, or you will break many plugins, which * generally use this hook to add elements to <head> such * as styles, scripts, and meta tags. */ wp_head(); ?> </head> <body <?php body_class(); ?>> <div id="page" class="hfeed"> <header id="branding" role="banner"> <hgroup> <h1 id="site-title"><span><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></span></h1> <h2 id="site-description"><?php bloginfo( 'description' ); ?></h2> </hgroup> <?php // Check to see if the header image has been removed $header_image = get_header_image(); if (is_home() || is_front_page()) : ?> <div class="headerslider"> <?php echo do_shortcode('[sp_responsiveslider limit="-1"]'); ?></div> <?php elseif ( $header_image ) : // Compatibility with versions of WordPress prior to 3.4. if ( function_exists( 'get_custom_header' ) ) { /* * We need to figure out what the minimum width should be for our featured image. * This result would be the suggested width if the theme were to implement flexible widths. */ $header_image_width = get_theme_support( 'custom-header', 'width' ); } else { $header_image_width = HEADER_IMAGE_WIDTH; } ?> <a href="<?php echo esc_url( home_url( '/' ) ); ?>"> <?php /* * The header image. * Check if this is a post or page, if it has a thumbnail, and if it's a big one */ if ( is_singular() && has_post_thumbnail( $post->ID ) && ( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( $header_image_width, $header_image_width ) ) ) && $image[1] >= $header_image_width ) : // Houston, we have a new header image! echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' ); else : // Compatibility with versions of WordPress prior to 3.4. if ( function_exists( 'get_custom_header' ) ) { $header_image_width = get_custom_header()->width; $header_image_height = get_custom_header()->height; } else { $header_image_width = HEADER_IMAGE_WIDTH; $header_image_height = HEADER_IMAGE_HEIGHT; } ?> <img src="<?php header_image(); ?>" width="<?php echo $header_image_width; ?>" height="<?php echo $header_image_height; ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" /> <?php endif; // end check for featured image or standard header ?> </a> <?php endif; // end check for removed header image ?> <nav id="access" role="navigation"> <h3 class="assistive-text"><?php _e( 'Main menu', 'twentyeleven' ); ?></h3> <?php /* Allow screen readers / text browsers to skip the navigation menu and get right to the good stuff. */ ?> <div class="skip-link"><a class="assistive-text" href="#content"><?php _e( 'Skip to primary content', 'twentyeleven' ); ?></a></div> <?php if ( ! is_singular() ) : ?> <div class="skip-link"><a class="assistive-text" href="#secondary"><?php _e( 'Skip to secondary content', 'twentyeleven' ); ?></a></div> <?php endif; ?> <?php /* Our navigation menu. If one isn't filled out, wp_nav_menu falls back to wp_page_menu. The menu assigned to the primary location is the one used. If one isn't assigned, the menu with the lowest ID is used. */ ?> <?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?> </nav><!-- #access --> </header><!-- #branding --> <div id="main">Ach und noch was, wenn du hier Code postest bitte die Code-Buttons verwenden.
-
Hallo Maxe,
kann die header.php gerade nicht ausprobieren, da ich lokal mit xampp arbeite und momentan nicht an dem Rechner arbeite. Den Code des Sliders hatte ich übrigens an verschiedenen Stellen in der header.php ausprobiert, bis der slider an der korrekten Stelle saß. Nämlich im Header der Seite. Hatte vorher den Abstand oben zum Browserrand etwas erhöht - besteht da evt. ein Zusammenhang? Das er an der "richtigen" Stelle im Code, an der falschen Stelle auf der Seite angezeigt wurde?
Gruß
Ulli -
Hallo Maxe,
hier nochmal Ulli. Habe deine header.php nun getestet und sie funktioniert auch. Leider erscheint auf der Seite links unter dem Header diese Zeile aus den code: [COLOR=#373737][FONT=Helvetica Neue]elseif ( $header_image ) :
Es ist schon merkwürdig, habe an einer anderen wordpress-Installation mit dem twentyeleven-theme nochmals alles probiert, wenn ich erst die Beitragsbilder einsetze auf den einzelnen Seiten, dann den Slider installiere, dann den Abstand zum oberen Rand vergrößere und schließlich das Headerbild unter Design entferne, funktioniert alles, bis auf das kleine Problem mit der Zeile, wie oben beschrieben. Es kommt also auch auf die Reihenfolge der Änderungen an, oder?
Gruß
Ulli[/FONT][/COLOR]
Jetzt mitmachen!
Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!