• Resolved irkevin

    (@irkevin)


    Hi all,

    Can anyone show me how to make an sql to fetch subcategories?

    I don’t want to use wp_list_categories(“child_of=<id>”)

    I have to create an SQL to fetch the subcategories if i want to paginate them.

    I know SQL, but the way wordpress DB is setup makes it hard for me

    How should write the SQL?

    Help plz

Viewing 2 replies - 16 through 17 (of 17 total)
  • Amazing!!!!! it works, right now I can’t do work with permalinks but I try later, I don’t know why don’t do now…

    I don’t know if can be show the list in cols, I find some code than put the list in cols but don’t have too much knowledge of php to put both together, maybe someone can help me here…

    This is the code to show the list of categories in two cols:

    $cats = explode("<br />",wp_list_categories('child_of=1&echo=0&hide_empty=0&orderby=ID&style=none&title_li='));
    $cat_n = count($cats) - 1;
    for ($i=0;$i<$cat_n;$i++):
    if ($i<$cat_n/2):
    $cat_left = $cat_left.'<li>'.$cats[$i].'</li>';
    elseif ($i>=$cat_n/2):
    $cat_right = $cat_right.'<li>'.$cats[$i].'</li>';
    endif;
    endfor;
    
    echo '<ul class="left">';
    echo $cat_left;
    echo '</ul>';
    echo '<ul class="right">';
    echo $cat_right;
    echo '</ul>';

    I have this working however due to the huge number of subcategories that I have it, and it does not use the same logic as the plugin (only listing so many pages, instead you can view them all which goes out of the design). You can see what I mean here: http://www.songlyricsx.com/lyrics/a/

    Anyone have a solution for that?

Viewing 2 replies - 16 through 17 (of 17 total)
  • The topic ‘Custom sql for subcategories – for use in pagination’ is closed to new replies.