Visualizzazione dei risultati da 1 a 9 su 9
  1. #1

    codice PHP in child theme scorretto

    Ciao a tutti, capisco poco del Vs mondo ma sto studiando. In questo momento ho da chiedervi un problema per me insormontabile!

    Sto modificando il file function di un tema child cioè sto cercando di dargli diverse istruzioni per le funzioni.

    Ho scritto il seguente codice che è la somma di più condizioni diverse, ciascuna per ogni funzione del tema. La prima parte del codice funziona, cioè quella relativa alla prima condizione. Quando però cerco di avviare una catena sul mio bel file functions (del tema child) di condizioni mi appare la pagina bianca, quasi certamente per un errore di sintassi. Potete indicarmi quale sia l'errore e perché?
    A leggere gli articoli su internet comprendo quali siano le problematiche del codice ma mi manca l'esperienza per scriverlo e certamente c'è qualche problema.

    vi ringrazio in anticipo. Il codice che ho scritto è questo e vi scrivo solo le prime due perché penso che il problema stia tra la prima e la seconda (per intuizione).

    <?php
    if ( ! function_exists( 'bavotasan_widgets_init' ) ) {


    function bavotasan_widgets_init() {
    $bavotasan_theme_options = bavotasan_theme_options();


    register_sidebar( array(
    'name' => __( 'First Sidebar', 'destin' ),
    'id' => 'sidebar',
    'description' => __( 'This is the first sidebar. It won&rsquo;t appear on the home page unless you set a static front page.', 'destin' ),
    'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    'after_widget' => '</aside>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    &nbsp );


    register_sidebar( array(
    'name' => __( 'Second Sidebar', 'destin' ),
    'id' => 'second-sidebar',
    'description' => __( 'This is the second sidebar. It won&rsquo;t appear on the home page unless you set a static front page and have added at least one widget.', 'destin' ),
    'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    'after_widget' => '</aside>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    &nbsp );


    register_sidebar( array(
    'name' => __( 'Home Page Corner', 'destin' ),
    'id' => 'home-page-corner',
    'description' => __( 'Area in the top right on the home page. Add at least one widget to make it appear.', 'destin' ),
    'before_widget' => '<aside id="%1$s" class="home-widget %2$s">',
    'after_widget' => '</aside>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    &nbsp );


    register_sidebar( array(
    'name' => __( 'Extended Footer', 'destin' ),
    'id' => 'extended-footer',
    'description' => __( 'This is the extended footer. You can set the number of columns in the customizer. Add at least one widget to make it appear.', 'destin' ),
    'before_widget' => '<aside id="%1$s" class="footer-widget ' . esc_attr( $bavotasan_theme_options['extended_footer_columns'] ) . ' %2$s">',
    'after_widget' => '</aside>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    &nbsp );


    register_sidebar( array(
    'name' => __( 'Footer Notice', 'destin' ),
    'id' => 'footer-notice',
    'description' => __( 'This is the footer notice area. It works best with a copyright notice or a banner ad.', 'destin' ),
    'before_widget' => '<aside id="%1$s" class="footer-notice pull-left %2$s">',
    'after_widget' => '</aside>',
    'before_title' => '',
    'after_title' => '',
    &nbsp );


    register_sidebar( array(
    'name' => __('Header', 'twentyeleven'),
    'id' => 'header',
    'description' => __('An optional widget area for your site header', 'twentyeleven'),
    'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    'after_widget' => '</aside>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    ) );


    }


    }


    ?>


    <?php
    if ( ! function_exists( 'bavotasan_front_page_render' ) ) {


    function bavotasan_front_page_render() {
    global $wp_query, $paged;
    ?>
    <?php while ( have_posts() ) : the_post(); ?>
    <?php if ( is_front_page() ) { ?>
    <div class="item">
    <figure class="effect-julia">
    <?php
    if ( has_post_thumbnail() )
    the_post_thumbnail( 'home' );
    else
    echo '<img src="' . BAVOTASAN_THEME_URL . '/library/images/no-image.jpg" alt="" />';
    ?>
    <figcaption>
    <h2><?php the_title(); ?></h2>
    <div>
    <p><?php echo wp_trim_words( strip_shortcodes( get_the_excerpt() ) , 10 ); ?></p>
    <p class="more-link-p"><?php _e( 'Continua a leggere <span class="meta-nav">&rarr;</span>', 'destin' ); ?></p>
    </div>
    <a href="<?php the_permalink(); ?>"><?php _e( 'View more', 'destin' ); ?></a>
    </figcaption>
    </figure>
    </div>
    <?php } else { ?>
    <?php get_template_part( 'content', get_post_format() ); ?>
    <?php } ?>
    <?php endwhile; ?>
    <?php
    }
    }

    ?>

    Grazie a tutti,
    Andrea

  2. #2
    Ecco per esempio, ho scoperto che copiando dentro vengono fuori le Emoticos... chiaramente nel codice non sono emoticons ma il punto virgola e la parentesi...

  3. #3
    Utente di HTML.it L'avatar di badaze
    Registrato dal
    Jun 2002
    residenza
    Lyon
    Messaggi
    5,372
    Devi racchiudere il codice tra i tag [.PHP] [./PHP] senza i punti.
    Ridatemi i miei 1000 posts persi !!!!
    Non serve a nulla ottimizzare qualcosa che non funziona.
    Cerco il manuale dell'Olivetti LOGOS 80B - www.emmella.fr

  4. #4
    Quote Originariamente inviata da badaze Visualizza il messaggio
    Devi racchiudere il codice tra i tag [.PHP] [./PHP] senza i punti.
    Ciao, grazie per la risposta. Prendimi per un rimbambito se vuoi ... ma di quali punti parli?

  5. #5
    Moderatore di PHP L'avatar di Alhazred
    Registrato dal
    Oct 2003
    Messaggi
    12,505
    quelli che ha messo dentro le parentesi quadre, li ha messi perché altrimenti i tag sarebbero stati interpretati e non visualizzati nel messaggio.

  6. #6
    No, scusatemi, mi sento preso in giro... lo capisco che mi state cercando di aiutare ma io non vedo neppure le parentesi quadre!
    riprovo a mettere il codice nella maniera corretta, se ho capito come si fa. E' lo stesso. Parentesi quadre non ce ne sono, neppure a cercarle con il finder nell'editor del file che ho sul desktop.

    <?php
    if ( ! function_exists( 'bavotasan_widgets_init' ) ) {


    function bavotasan_widgets_init() {
    $bavotasan_theme_options = bavotasan_theme_options();


    register_sidebar( array(
    'name' => __( 'First Sidebar', 'destin' ),
    'id' => 'sidebar',
    'description' => __( 'This is the first sidebar. It won&rsquo;t appear on the home page unless you set a static front page.', 'destin' ),
    'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    'after_widget' => '</aside>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    ) );


    register_sidebar( array(
    'name' => __( 'Second Sidebar', 'destin' ),
    'id' => 'second-sidebar',
    'description' => __( 'This is the second sidebar. It won&rsquo;t appear on the home page unless you set a static front page and have added at least one widget.', 'destin' ),
    'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    'after_widget' => '</aside>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    ) );


    register_sidebar( array(
    'name' => __( 'Home Page Corner', 'destin' ),
    'id' => 'home-page-corner',
    'description' => __( 'Area in the top right on the home page. Add at least one widget to make it appear.', 'destin' ),
    'before_widget' => '<aside id="%1$s" class="home-widget %2$s">',
    'after_widget' => '</aside>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    ) );


    register_sidebar( array(
    'name' => __( 'Extended Footer', 'destin' ),
    'id' => 'extended-footer',
    'description' => __( 'This is the extended footer. You can set the number of columns in the customizer. Add at least one widget to make it appear.', 'destin' ),
    'before_widget' => '<aside id="%1$s" class="footer-widget ' . esc_attr( $bavotasan_theme_options['extended_footer_columns'] ) . ' %2$s">',
    'after_widget' => '</aside>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    ) );


    register_sidebar( array(
    'name' => __( 'Footer Notice', 'destin' ),
    'id' => 'footer-notice',
    'description' => __( 'This is the footer notice area. It works best with a copyright notice or a banner ad.', 'destin' ),
    'before_widget' => '<aside id="%1$s" class="footer-notice pull-left %2$s">',
    'after_widget' => '</aside>',
    'before_title' => '',
    'after_title' => '',
    ) );


    register_sidebar( array(
    'name' => __('Header', 'twentyeleven'),
    'id' => 'header',
    'description' => __('An optional widget area for your site header', 'twentyeleven'),
    'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    'after_widget' => '</aside>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    ) );


    }


    }


    ?>


    <?php
    if ( ! function_exists( 'bavotasan_front_page_render' ) ) {


    function bavotasan_front_page_render() {
    global $wp_query, $paged;
    ?>
    <?php while ( have_posts() ) : the_post(); ?>
    <?php if ( is_front_page() ) { ?>
    <div class="item">
    <figure class="effect-julia">
    <?php
    if ( has_post_thumbnail() )
    the_post_thumbnail( 'home' );
    else
    echo '<img src="' . BAVOTASAN_THEME_URL . '/library/images/no-image.jpg" alt="" />';
    ?>
    <figcaption>
    <h2><?php the_title(); ?></h2>
    <div>
    <p><?php echo wp_trim_words( strip_shortcodes( get_the_excerpt() ) , 10 ); ?></p>
    <p class="more-link-p"><?php _e( 'Continua a leggere <span class="meta-nav">&rarr;</span>', 'destin' ); ?></p>
    </div>
    <a href="<?php the_permalink(); ?>"><?php _e( 'View more', 'destin' ); ?></a>
    </figcaption>
    </figure>
    </div>
    <?php } else { ?>
    <?php get_template_part( 'content', get_post_format() ); ?>
    <?php } ?>
    <?php endwhile; ?>
    <?php
    }
    }

    endif; ?>

  7. #7
    Che scemo! Scusami Alhazred, ho capito cosa volevi dire! Ho capito cosa volevate dirmi entrambi... io cercavo nel mio codice...

    Grazie mille, ora provo.

  8. #8
    Non funziona... funziona solo con la prima parte del codice. C'� qualcosa che lo irita nella seconda parte del codice. Grazie comunque, continuo e poi vi faccio sapere.

  9. #9
    Moderatore di PHP L'avatar di Alhazred
    Registrato dal
    Oct 2003
    Messaggi
    12,505
    Codice PHP:

    <?php
    if ( ! function_exists'bavotasan_widgets_init' ) ) {


    function 
    bavotasan_widgets_init() {
    $bavotasan_theme_options bavotasan_theme_options();


    register_sidebar( array(
    'name' => __'First Sidebar''destin' ),
    'id' => 'sidebar',
    'description' => __'This is the first sidebar. It won&rsquo;t appear on the home page unless you set a static front page.''destin' ),
    'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    'after_widget' => '</aside>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    ) );


    register_sidebar( array(
    'name' => __'Second Sidebar''destin' ),
    'id' => 'second-sidebar',
    'description' => __'This is the second sidebar. It won&rsquo;t appear on the home page unless you set a static front page and have added at least one widget.''destin' ),
    'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    'after_widget' => '</aside>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    ) );


    register_sidebar( array(
    'name' => __'Home Page Corner''destin' ),
    'id' => 'home-page-corner',
    'description' => __'Area in the top right on the home page. Add at least one widget to make it appear.''destin' ),
    'before_widget' => '<aside id="%1$s" class="home-widget %2$s">',
    'after_widget' => '</aside>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    ) );


    register_sidebar( array(
    'name' => __'Extended Footer''destin' ),
    'id' => 'extended-footer',
    'description' => __'This is the extended footer. You can set the number of columns in the customizer. Add at least one widget to make it appear.''destin' ),
    'before_widget' => '<aside id="%1$s" class="footer-widget ' esc_attr$bavotasan_theme_options['extended_footer_columns'] ) . ' %2$s">',
    'after_widget' => '</aside>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    ) );


    register_sidebar( array(
    'name' => __'Footer Notice''destin' ),
    'id' => 'footer-notice',
    'description' => __'This is the footer notice area. It works best with a copyright notice or a banner ad.''destin' ),
    'before_widget' => '<aside id="%1$s" class="footer-notice pull-left %2$s">',
    'after_widget' => '</aside>',
    'before_title' => '',
    'after_title' => '',
    ) );


    register_sidebar( array(
    'name' => __('Header''twentyeleven'),
    'id' => 'header',
    'description' => __('An optional widget area for your site header''twentyeleven'),
    'before_widget' => '<aside id="%1$s" class="widget %2$s">',
    'after_widget' => '</aside>',
    'before_title' => '<h3 class="widget-title">',
    'after_title' => '</h3>',
    ) );


    }


    }


    ?>


    <?php
    if ( ! function_exists'bavotasan_front_page_render' ) ) {


    function 
    bavotasan_front_page_render() {
    global 
    $wp_query$paged;
    ?>
    <?php 
    while ( have_posts() ) : the_post(); ?>
    <?php 
    if ( is_front_page() ) { ?>
    <div class="item">
    <figure class="effect-julia">
    <?php
    if ( has_post_thumbnail() )
    the_post_thumbnail'home' );
    else
    echo 
    '<img src="' BAVOTASAN_THEME_URL '/library/images/no-image.jpg" alt="" />';
    ?>
    <figcaption>
    <h2><?php the_title(); ?></h2>
    <div>
    <p><?php echo wp_trim_wordsstrip_shortcodesget_the_excerpt() ) , 10 ); ?></p>
    <p class="more-link-p"><?php _e'Continua a leggere <span class="meta-nav">&rarr;</span>''destin' ); ?></p>
    </div>
    <a href="<?php the_permalink(); ?>"><?php _e'View more''destin' ); ?></a>
    </figcaption>
    </figure>
    </div>
    <?php } else { ?>
    <?php get_template_part
    'content'get_post_format() ); ?>
    <?php 
    ?>
    <?php 
    endwhile; ?>
    <?php
    }
    }

    endif; 
    ?>

Tag per questa discussione

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.