Rezultate 1 la 2 din 2

Subiect: Cum afisam articolele recente in wordpress?

  1. #1
    Avatarul lui Prietenul
    Prietenul este deconectat Banned
    Reputatie:
    0
    Data înscrierii
    25th March 2013
    Locaţie
    Bucuresti
    Vârstă
    54
    Posturi
    81
    Putere Rep
    0


    Implicit Cum afisam articolele recente in wordpress?

    Salutare,
    Azi as dorii sa va ofer un mic tool care-l folosesc pe theme mele custom made WP.
    Daca doriti sa editati o themea deja existenta sau doriti sa faceti voi una si doriti sa afisati sa zicem.... 4 coloane cu cele mai recente articole postate aveti nevoie de urmatorul cod :

    Cod PHP:
    <?php
    // code to display a number of posts in multi columns top-to-bottom left-to-right
    ?>
    <?php 
    global $query_string?>
    <?php
    $set_number_of_columns 
    4// enter numbers of columns here;
    $set_number_of_rows 1// enter numbers of rows here
    $set_showpost $set_number_of_columns $set_number_of_rows ;
    //setup query with parameter for paged
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts($query_string.'&showposts='.$set_showpost.'&paged='.$paged);
    // get number of posts for this,
    $num_of_posts $wp_query->post_count;
    // make adjustment for paged to get three equaly long columns even on last paged page
    // divide by $set_number_of_columns to get number per column,
    // round up to next integer to make $ppc posts per column variable, or $set_number_of_rows whatever is smaller
    $ppc min(ceil($num_of_posts/$set_number_of_columns),$set_number_of_rows);
    // calculates number of rows, i.e. showposts for the following query_posts and get_posts
    ?>
    <?php 
    for ( $col 1$col <= $set_number_of_columns$col += 1) { ?>
    <div class="col<?php echo $col;?>">
    <?php
    $row 
    1;
    $noffset = ($col -1) * $ppc + ($paged 1) * $set_showpost //calculate offset parameter if paged
    $posts get_posts($query_string.'&numberposts='.$ppc.'&offset='.$noffset);
    foreach (
    $posts as $post) : start_wp(); ?>
    <div id="post-<?php the_ID(); ?>" class="post row-<?php echo ($row%2); ?>">
    <!-- start of anything to do with post -->
    <a href="<?php the_permalink() ?>"><?php the_post_thumbnail(); ?></a>
    <h3>
    <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
    <div class="storycontent">
    <?php the_excerpt(__('(more...)')); ?>
    </div>
    <!-- end of anything to do with post -->
    </div> <!-- end #post -->
    <?php
    $row
    ++;
    endforeach; 
    ?>
    </div>
    <?php ?>
    E cam lung carnatul, dar asta e. Eu nu am reusit insa sa fac asta pe prima pagina a themei de wp. Ma refer ca.. pe o pagina gen "page.php" sau un template de pagina wp reusiesc sa integrez codul insa trebuie sa setez wp ca prima pagina sa fie una statica. si asta nu prea-mi convine.

    Haideti ca poate eu pun ceva util pentru cei care nu stiau asta si in acelasi timp ma invatati si pe mine cum pot afisa postarile din blog pe prima pagina a unui wp dinamic fara pagina statica.

    Toate bune!

  2. #2
    Avatarul lui dexter
    dexter este deconectat Membru SeoPedia
    Reputatie:
    39
    Data înscrierii
    28th April 2005
    Vârstă
    42
    Posturi
    213
    Putere Rep
    39


    Implicit

    Pai destul de simplu poti rezolva....

    Poti face o pagina home.php si sa pui codul.... bineinteles + functiile get_header si get_footer

    Automat pe homepage Wordpress incearca sa foloseasca fisierul home.php, daca acest fisier nu exista apoi incearca sa includa index.php

    [editat apoi] ma refer sa pui home.php in folderul temei....
    Nu forta, foloseste un ciocan mai mare.
    Stiri IT, calculatoare, telefoane

Informații subiect

Utilizatori care navighează în acest subiect

Momentan este/sunt 1 utilizator(i) care navighează în acest subiect. (0 membrii și 1 vizitatori)

Thread-uri Similare

  1. Cum afisam data curenta in contentul din wordpress?
    De Prietenul în forumul WordPress
    Răspunsuri: 4
    Ultimul Post: 17th April 2013, 11:27
  2. Cum afisam articole random in wordpress?
    De Prietenul în forumul WordPress
    Răspunsuri: 0
    Ultimul Post: 12th April 2013, 11:00
  3. Citate in articolele de pe Wordpress ca in ziar
    De Bogdan Calin în forumul Subiecte pentru incepatori
    Răspunsuri: 13
    Ultimul Post: 12th June 2012, 10:46
  4. imi copiaza articolele
    De daniweb în forumul Plagiat
    Răspunsuri: 9
    Ultimul Post: 28th July 2009, 08:12
  5. Răspunsuri: 6
    Ultimul Post: 19th October 2005, 12:29

Permisiuni postare

  • Nu puteţi posta subiecte noi.
  • Nu puteţi răspunde la subiecte
  • Nu puteţi adăuga ataşamente
  • Nu puteţi modifica posturile proprii
  •