Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 12
  1. #1
    Utente di HTML.it L'avatar di alexite
    Registrato dal
    Apr 2007
    Messaggi
    130

    anteprima dei post di blog nella home .. come si fa?

    Salve a tutti ... una piccola info riguardo wordpress:
    qualcuno sa dirmi come fare a mostrare un'anteprima degli ultimi post del blog nella mia home?
    magari con il titolo, un'immagine (se caricata) e una parte di testo con il "read more"? il mio template (che tra l'altro ho modificato) non prevedeva questa cosa, quindi credo che vada aggiunta al codice ...
    grazie in anticipo
    ciaoooooooo by Alex!!!!!!

  2. #2
    Utente di HTML.it
    Registrato dal
    Nov 2006
    Messaggi
    656
    in primis devi modificare il template.

    il file index.php se non sbaglio.

    poi devi usare qualche plugin per mostrare l'ultimo post.

  3. #3
    Posta index.php e functions.php

  4. #4
    Utente di HTML.it L'avatar di alexite
    Registrato dal
    Apr 2007
    Messaggi
    130
    premetto che il template della home l'ho già modificato in base alle caratteristiche che richiedeva il cliente...

    comunque questo è il template della index:

    codice:
    <?php /* Template Name: temp_index */ ?> 
    <?php get_header(); ?> 
    <?php global $options; foreach ($options as $value) { if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); } } ?> 
    <div id="prologue"> 
    <div class="column last span-24"> 
    <div id="image_home"> 
    </div> 
    </div> 
    <div id="area_sinistra_home"> 
    </div> 
    </div> 
    <div id="secondary"> 
    <ul class="widget"> 
    <li class="ads_default"> 
    <h3>MUSIC PLAYER</h3> 
    <div id="music_player"> 
    </div> 
     
    <li class="ads_default"> 
    <h3>EXPLORE NEUROTRAXX</h3> 
    <div id="other_space"> 
    </div> 
      [/list]
     
    </div> 
     
    <?php get_footer(); ?>
    mentre questo è il file function:

    codice:
    <?php
    if ( function_exists('register_sidebar') )
        register_sidebar(array(
            'before_title' => '<h3>',
            'after_title' => '</h3>',
        ));
        
        
    function widget_mytheme_search() {
    ?>
        <li class="widget">
          <h3>SEARCH</h3>
          <form method="get" id="searchform2" action="<?php bloginfo('url'); ?>/">
          <div><input type="text" value="<?php the_search_query(); ?>" name="s" id="s2" /></div>
          <div><input type="submit" id="searchsubmit2" value="Search" /></div>
          </form>
        
    <?php
    }
    if ( function_exists('register_sidebar_widget') )
        register_sidebar_widget(__('Search'), 'widget_mytheme_search');
    
        
    $themename = "SimplePlease";
    $shortname = "SimplePlease";
    $options = array (
    
        array(  "name" => "Prologue Header Text (Grey Box on Top of Home Page)",
                "id" => "prologue_header",
                "std" => "Welcome!",
                "type" => "text"),
        
        array(  "name" => "Prologue Text",
                "id" => "prologue_text",
                "std" => "Please enjoy your stay, and subscribe to our RSS feed if you like what you see here.",
                "type" => "textarea"),
                
        array(  "name" => "Featured Category 1 (Bottom Left Column on Front Page)",
                "id" => "featured_cat_1",
                "std" => "1",
                "type" => "text"),
    
        array(  "name" => "Featured Category 2 (Bottom Right Column on Front Page)",
                "id" => "featured_cat_2",
                "std" => "2",
                "type" => "text"),
        
        array(  "name" => "Ad 1 Image URL",
                "id" => "ad1_img",
                "std" => "http://www.amgamers.com/simpleplease/wp-content/themes/simpleplease/images/ad2.jpg",
                "type" => "text"),
        
        array(  "name" => "Ad 1 Link URL",
                "id" => "ad1_link",
                "std" => "#",
                "type" => "text"),
        
        array(  "name" => "Ad 1 Alt Text",
                "id" => "ad1_alt",
                "std" => "#",
                "type" => "text"),
        
        array(  "name" => "Ad 2 Image URL",
                "id" => "ad2_img",
                "std" => "http://www.amgamers.com/simpleplease/wp-content/themes/simpleplease/images/ad2.jpg",
                "type" => "text"),
        
        array(  "name" => "Ad 2 Link URL",
                "id" => "ad2_link",
                "std" => "#",
                "type" => "text"),
        
        array(  "name" => "Ad 2 Alt Text",
                "id" => "ad2_alt",
                "std" => "#",
                "type" => "text"),
        
        array(  "name" => "Ad 3 Image URL",
                "id" => "ad3_img",
                "std" => "http://www.amgamers.com/simpleplease/wp-content/themes/simpleplease/images/ad2.jpg",
                "type" => "text"),
        
        array(  "name" => "Ad 3 Link URL",
                "id" => "ad3_link",
                "std" => "#",
                "type" => "text"),
        
        array(  "name" => "Ad 3 Alt Text",
                "id" => "ad3_alt",
                "std" => "#",
                "type" => "text"),
        
        array(  "name" => "Ad 4 Image URL",
                "id" => "ad4_img",
                "std" => "http://www.amgamers.com/simpleplease/wp-content/themes/simpleplease/images/ad2.jpg",
                "type" => "text"),
        
        array(  "name" => "Ad 4 Link URL",
                "id" => "ad4_link",
                "std" => "#",
                "type" => "text"),
        
        array(  "name" => "Ad 4 Alt Text",
                "id" => "ad4_alt",
                "std" => "#",
                "type" => "text"),
    
      );
      
      
    function mytheme_add_admin() {
    
        global $themename, $shortname, $options;
    
        if ( $_GET['page'] == basename(__FILE__) ) {
        
            if ( 'save' == $_REQUEST['action'] ) {
    
                    foreach ($options as $value) {
                        update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
    
                    foreach ($options as $value) {
                        if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ]  ); } else { delete_option( $value['id'] ); } }
    
                    header("Location: themes.php?page=functions.php&saved=true");
                    die;
    
            } else if( 'reset' == $_REQUEST['action'] ) {
    
                foreach ($options as $value) {
                    delete_option( $value['id'] ); }
    
                header("Location: themes.php?page=functions.php&reset=true");
                die;
    
            }
        }
    
        add_theme_page($themename." Options", "Simple Please Settings", 'edit_themes', basename(__FILE__), 'mytheme_admin');
    
    }
    
    function mytheme_admin() {
    
        global $themename, $shortname, $options;
    
        if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade">
    
    '.$themename.' settings saved.</p></div>';
        if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade">
    
    '.$themename.' settings reset.</p></div>';
    
    ?>
    <div class="wrap">
    <h2><?php echo $themename; ?> settings</h2>
    You may edit the standard settings for the Simple Please theme from this menu.
    
    
    
    <form method="post">
    
    <table class="optiontable">
    
    <?php foreach ($options as $value) { 
        
    if ($value['type'] == "text") { ?>
            
    <tr valign="top">
        <th scope="row" style="text-align:left;width:200px;padding-bottom:40px;"><?php echo $value['name']; ?>:</th>
        <td>
            <input name="<?php echo $value['id']; ?>" size="100" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?>" />
        </td>
    </tr>
    
    <?php } elseif ($value['type'] == "textarea") { ?>
    
    <tr valign="top">
        <th scope="row" style="text-align:left;width:200px;padding-bottom:40px;"><?php echo $value['name']; ?>:</th>
        <td style="padding-bottom:40px;">
    <textarea name="<?php echo $value['id']; ?>" rows="7" cols="50" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?>">
    <?php if ( get_settings( $value['id'] ) != "") { echo get_settings( $value['id'] ); } else { echo $value['std']; } ?>
    </textarea>
        </td>
    </tr>
    
    <?php 
    }
    }
    ?>
    
    </table>
    
    <p class="submit">
    <input name="save" type="submit" value="Save changes" />    
    <input type="hidden" name="action" value="save" />
    </p>
    </form>
    <form method="post">
    <p class="submit">
    <input name="reset" type="submit" value="Reset" />
    <input type="hidden" name="action" value="reset" />
    </p>
    </form>
    
    <?php
    }
    
    function mytheme_wp_head() { ?>
    
    <?php }
    
    add_action('wp_head', 'mytheme_wp_head');
    add_action('admin_menu', 'mytheme_add_admin'); ?>
    nel div "area_sinistra_home" sto cercando di far apparire i post ...
    ho trovato dei plugin ... uno in particolare (evermore) ma onestamente non sono riuscito ad utilizzarlo in questo sito!!
    Inizialmente il sito era pensato in modo da avere il blog nella home, quindi ho dovuto crearmi un template apposito per la index ..
    comunque grazie
    ciaoooooooo by Alex!!!!!!

  5. #5
    E' un topic ciclico...

    Dai un'occhiata a questo tutorial: http://blog.ipnext.it/?p=367

  6. #6
    Utente di HTML.it L'avatar di alexite
    Registrato dal
    Apr 2007
    Messaggi
    130
    mmmm sembra quello che fa al caso mio in effetti ... anche se comunque il sito che sto realizzando è tutto made in wordpress
    provo con questo tutorial e ci sentiamo ad opera completa, grazie
    ciaoooooooo by Alex!!!!!!

  7. #7
    Se ti interessa qualcosa tipo Ultimi articoli che trovi nella sidebar del mio blog (vedi in firma), ti posso passare il codice.

  8. #8
    Utente di HTML.it L'avatar di alexite
    Registrato dal
    Apr 2007
    Messaggi
    130
    è esattamente quello che hai nel tuo sito!!!
    titolo del post con la miniatura dell'immagine caricata
    nel mio caso, vabbè, l'immagine deve essere più grande e possibilmente avere anche qualche parola del post .. ma comunque è quello che intendevo!!!!!!!
    Hai una guida-tutorial oppure sai spiegarmi come farlo?



    comunque c'hai preso in pieno!!!!
    ciaoooooooo by Alex!!!!!!

  9. #9
    Ti posto qui un estratto leggermente modificato:
    codice:
    <ul>
    <?php query_posts('showposts=5'); ?>
    <?php while ( have_posts() ) : the_post(); ?> [*]
    <div class="thumbpost">
    <?php if(has_post_thumbnail()) { the_post_thumbnail( array(40,40) );
    } else { echo '[img]'.get_bloginfo([/img]" />';
    } ?>
    </div>
    <h4 class="alignleft">"><?php the_title(); ?></h4>
    
    <span class="minitxt"><?php the_time('d F Y'); ?> postato da <?php the_author(); ?></span>
    <?php the_excerpt(); ?>
    
    <?php endwhile; ?> [/list]
    Il 40,40 è la misura della miniatura, può non funzionare, dipenderà se hai attivato il supporto alle thumbnails

    Ho aggiunto the_excerpt (che nel mio tema non c'è), anche qui volendo puoi gestire quante parole inserire nell'estratto del post aggiungendo qualche riga in functions.php

    Ho lasciato i vari riferimenti allo style così com'erano, cambia o aggiungi tu secondo le tue esigenze.

  10. #10
    Utente di HTML.it L'avatar di alexite
    Registrato dal
    Apr 2007
    Messaggi
    130
    stupendo!!!!! ho provato e funziona.. poi lo stile me lo modifico ma è quello che cercavo grazie

    dipenderà se hai attivato il supporto alle thumbnails
    ti spiego ... mi sono imparato wordpress praticamente in 2 settimane di studio intenso e ancora alcune cose non le conosco bene ... quale supporto dovrei attivare?
    L'idea era che una foto caricata dentro al post del blog si potesse vedere come miniatura nella home ..
    ciaoooooooo by Alex!!!!!!

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 © 2024 vBulletin Solutions, Inc. All rights reserved.