php – How to perform post queries with numbers 0-9 and special characters in wordpress-ThrowExceptions

Exception or error:

Hello I would like to know how I can make the specific query of posts on wordpress that do not start with letters from A to Z, such as numbers 0-9, special characters, and any title that does not start with an alphabetical letter.

I am using this code.

Creates links with letters from A to Z

function doo_glossary( $type = 'all') {
    // main codition
    if( DOO_THEME_GLOSSARY != false ) {
        echo '<div class="letter_home"><div class="fixresp"><ul class="glossary">';
        echo '<li><a class="lglossary" href="'.get_the_permalink().'">All</a></li>';
        for ($l="a";$l!="aa";$l++){
            echo '<li><a class="lglossary" href="'.get_the_permalink().'?letra='.strtolower($l).'">'. strtoupper($l). '</a></li>';
        }
        echo '</ul></div></div>';
    }
    }

Paging script

<?php
/*
Template Name: DT - Seção Série 01
*/
get_header();
$titulo = cs_get_option('series01title','Séries 01');
doo_glossary2('tvshows');
global $user_ID;
$dt = isset( $_GET['get'] ) ? $_GET['get'] : null;
echo '<div class="module"><div class="content">';
get_template_part('inc/parts/modules/featured-post-tvshows');
echo '<div id="archive-content" class="animation-2 items calendario">';
// Ordenar em ordem alfabetica
global $wp_query;
$pages = $wp_query->max_num_pages;
$first_char = $_GET['letra'];
// Permite ordenar os itens em 3 modos em ordem crescente ou decresente
$orde = cs_get_option('tvmodorderby2','date');
$ordr = cs_get_option('tvmodorder2','DESC');
$postids=$wpdb->get_col($wpdb->prepare("
SELECT      ID
FROM        $wpdb->posts
WHERE       SUBSTR($wpdb->posts.post_title,1,1) = %s
ORDER BY    $wpdb->posts.post_title",$first_char)); 

if (isset( $_GET['letra'] )) {
query_posts(array(
    'post__in'      => $postids,
    'posts_per_page' => $pages,
    'caller_get_posts'=> 1,
    'paged' => $paged,
    'post_status'   => 'publish',
    'post_type'     => array('tvshows'),
    'meta_key'      => 'tipo_de_serie',
    'meta_value'    => 'series01',
    'order'         => 'ASC',
    'orderby'       => 'title'
)); } else {

query_posts(array(
    'posts_per_page' => $pages,
    'paged' => $paged,
    'post_type'     => array('tvshows'),
    'meta_key'      => 'tipo_de_serie',
    'meta_value'    => 'series01',
    'order'         => $ordr,
    'orderby'       => $orde
));

}
if (have_posts()) {
echo '<header><h1>'. $titulo. '</h1><span>Total '.$wp_query->found_posts . '</span></header>';
    while (have_posts()) {
        the_post();
        get_template_part('inc/parts/item');
    }
}else { echo '<header><h1>'. $titulo. '</h1><span>Total '.$wp_query->found_posts . '</span></header>';
echo '<div class="wp-content">
<blockquote><p>No momento essa seção esta sem nenhum conteúdo, em breve ela sera ativada.</p></blockquote>
</div>'; }
echo '</div>';
doo_pagination();
echo '</div>';
get_template_part('inc/parts/sidebar');
echo '</div>';
get_footer();

I wonder how can I make consultations items that are not initiated by alphabetical letters. Adding to doo_glossary, a link #, which when clicked, shows all posts that do not start with alphabetic characters in a single query.

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *