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

    [Wordpress] problema con template pagina mio

    Salve a tutti, io avrei un problema che purtroppo non riesco a risolvere.
    Dato che me la cavo abbastanza con PHP ho deciso di creare un template pagina per il mio sito che gira in WP che (in teoria) dovrebbe estrarre dal database solo i POST (niente pagine, solo post) che cominciano per una determinata lettera (per esempio tutti i post che cominciano per "a").
    Purtroppo non ne sono stato capace
    Sono 3 giorni che ci provo ma niente...l'unica cosa che sono riuscito a fare è stato estrarre tutti i post presenti nel database e ordinarli...

    Codice PHP:
    <?php
    global $post;
    $tmp_post $post;
    $args = array( 'numberposts' => 0'offset'=> 0'category' => '1,2,3,4,5,6,7,8,9,10,11,12'post_type => 'post'orderby => 'title'order => 'ASC'nopaging => 'true');
    $myposts get_posts$args );
    foreach( 
    $myposts as $post ) : setup_postdata($post); ?>
        [*][url="<?php the_permalink(); ?>"]<?php the_title(); ?>[/url]
    <?php endforeach; ?>[/list]

    Qualcuno che conosce bene Wordpress è in grado di aiutarmi?

    Grazie infinite

  2. #2
    Utente di HTML.it L'avatar di echoweb
    Registrato dal
    Sep 2008
    Messaggi
    419
    Tramite la variabile $post, hai accesso al titolo del post in questo modo

    Codice PHP:
    $post->post_title 
    Adesso che hai il titolo come variabile, stampi a video il tag LI solo in base alle tue condizioni.

    Questa potrebbe essere un'idea...


    Codice PHP:
    <?php 
    global $post
    $tmp_post $post
    $args = array( 'numberposts' => 0'offset'=> 0'category' => '1,2,3,4,5,6,7,8,9,10,11,12'post_type => 'post'orderby => 'title'order => 'ASC'nopaging => 'true'); 
    $myposts get_posts$args ); 
    foreach( 
    $myposts as $post ) : setup_postdata($post); 

       
    $titolo_post $post->post_title;

       if(
    CONDIZIONE ...){ ?> 
    [*][url="<?php the_permalink(); ?>"]<?php the_title(); ?>[/url] 

    <?php  ?>

    <?php endforeach; ?> [/list]


    "Non soffocare la tua ispirazione e la tua immaginazione,
    non diventare lo schiavo del tuo modello"

    Vincent van Gogh

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.