2016-09-16 6 views
0

Gibt es sowieso oder ein Plugin für in der Auflistung a-z alphabetisch und wenn Sie auf ein Alphabet klicken, zeigt es Ihnen den Inhalt beginnt mit diesem Alpa. Die meisten Plugins müssen eins nach dem anderen jedes Item hinzufügen, das indiziert wird, was ich nicht will, weil ich schon eine lange Liste habe. BEISPIEL:Wordpress Beitrag im Artikel Alpahabetic Bestellung

A | B | C | D | E

BROS

BROTHER

Beggin

Like in this picture but this plugin also wants items add one by one

Antwort

0

Kein Plugin wirklich benötigt: https://wordpress.stackexchange.com/questions/67271/display-all-posts-starting-with-given-letter

Die Lösung, die für Sie nützlich sein kann (zB aus dem obigen Link genommen):

<ul class="posts"> 
    <?php 
    global $wpdb; 
    $request = "a" // could be any letter you want 
    $results = $wpdb->get_results(
      " 
      SELECT * FROM $wpdb->posts 
      WHERE post_title LIKE '$request%' 
      AND post_type = 'post' 
      AND post_status = 'publish'; 
      " 
    ); 
    if ($results) 
    { 
     foreach ($results as $post) 
     { 
      setup_postdata ($post); 
      ?> 
      <li> 
       ... loop stuff here (the_title, the_permalink) ... 
      </li> 
      <?php 
     } 
    } 
    else 
    { 
     ?> 
     <div class="alert">No clubs found for that letter. Please try again, or use the search at the top.</div> 
     <?php 
    } 
    ?> 
</ul> 

Sie könnten Ihre URLs mit einem $ _GET [] bekommen, so dass Sie den Code über das ändern kann:

<ul class="posts"> 
<?php 
    global $wpdb; 
    $request = 'a'; 
    if (isset($_GET[ "bl" ])) { 
     $request = sanitize_text_field($_GET[ "bl" ]); 
    } 
    $results = $wpdb->get_results(
      " 
      SELECT * FROM $wpdb->posts 
      WHERE post_title LIKE '$request%' 
      AND post_type = 'post' 
      AND post_status = 'publish'; 
      " 
    ); 
    if ($results) 
    { 
     foreach ($results as $post) 
     { 
      setup_postdata ($post); 
      ?> 
      <li> 
       //... loop stuff here (the_title, the_permalink) ... 
      </li> 
      <?php 
     } 
    } 
    else 
    { 
     ?> 
     <div class="alert">No content found for that letter.</div> 
     <?php 
    } 
    ?> 
</ul> 
Verwandte Themen