Support » Fixing WordPress » sort with alphabet

  • hi,
    how to sort my post alphabetically without post loop?
    (32 character= 32 loop)

    image:
    http://uupload.ir/files/7fk6_wewe.jpg

    my source code:

    <section class="alphabet-sort">
            <a href="#" class="active"><span>#</span></a>
            <a href="#"><span>A</span></a>
            <a href="#"><span>B</span></a>
            <a href="#"><span>C</span></a>
            <a href="#"><span>D</span></a>
            <a href="#"><span>E</span></a>
            <a href="#"><span>F</span></a>
            <a href="#"><span>G</span></a>
            <a href="#"><span>H</span></a>
            <a href="#"><span>I</span></a>
            <a href="#"><span>J</span></a>
            <a href="#"><span>K</span></a>
            <a href="#"><span>L</span></a>
            <a href="#"><span>M</span></a>
            <a href="#"><span>N</span></a>
            <a href="#"><span>O</span></a>
            <a href="#"><span>P</span></a>
            <a href="#"><span>Q</span></a>
            <a href="#"><span>R</span></a>
            <a href="#"><span>S</span></a>
            <a href="#"><span>T</span></a>
            <a href="#"><span>U</span></a>
            <a href="#"><span>V</span></a>
            <a href="#"><span>W</span></a>
            <a href="#"><span>X</span></a>
            <a href="#"><span>Y</span></a>
            <a href="#"><span>Z</span></a>
    
        </section>

    like this code. but how to work this??

    <div class="alphabets">
                        <?php
                            for( $i = 65; $i < 91; $i++)
                                if( isset( $_GET['n'] ) && preg_match( '/[a-zA-Z]{1}/', $_GET['n'] ) && ($_GET['n'] == chr($i)) )
                                    echo '<div class="abc active'. ($i==65? ' first':'') .'"><a href="'. get_post_type_archive_link('artist') .'">'.chr($i).'</a></div>';
                                else
                                    echo '<div class="abc '. ($i==65? ' first':'') .'"><a href="'. get_post_type_archive_link('artist') .'?n='.chr($i).'">'.chr($i).'</a></div>';
                            if( isset( $_GET['n'] )  && ($_GET['n'] == '0-9') )
                                echo '<div class="abc alpha active"><a href="'. get_post_type_archive_link('artist') .'">0-9</a></div>';
                            else
                                echo '<div class="abc alpha "><a href="'. get_post_type_archive_link('artist') .'?n=0-9">0-9</a></div>';
                        ?>
                    </div>

    and

    function is_first_character_persian( $text = '' ){
        $first = mb_substr($text, 0, 1, 'utf-8');
        $persian = array('ش','آ','ا','ب','پ','ت','س','ج','چ','ح','خ','د','ذ','ر','ز','ژ','س','ش','ص','ض','ط','ظ','ع','غ','ف','ق','ک','گ','ل','م','ن','و','ه','ی' );
        return in_array( $first, $persian );
    }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘sort with alphabet’ is closed to new replies.