Jump to content

jcpeden

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Posts posted by jcpeden

  1. I'm trying to count the number of files in a directory on my local server. When I browse to the directory I can see this:

     

    screen.jpg

     

    Here is the code that I'm using:

     

    $category = get_the_category();
    $cat_slug = $category[0]->category_nicename;
    $dir = 'http://localhost/badsexsucks/wp-content/themes/AskIt/images/gay/';
    
    if (glob("$dir*.jpg") != false)
    {
    $filecount = count(glob("" .$dir. "*.jpg"));
    
    echo $filecount;
    }
    else
    {
    echo 0;
    }
    

     

    For some reason, it always returns 0

     

    I've tried both:

    $dir = 'http://localhost/badsexsucks/wp-content/themes/AskIt/images/gay/';

    $dir = '../images/gay/'

  2. Here is what I've come up with. I've tested this code and the results are absolutely perfect for what I need. As I'm pretty much a beginner with PHP, please let me know if I've gone about it in an a$$ backward manner.

     

    // Get current category id and concatenate argument 'child_of=cat_id'

    function child_categories(&$current_cat_ID) {

    global $wp_query;

    $current_cat_ID .= get_query_var('cat');

    }

    $child_of = 'child_of=';

    child_categories($child_of);

     

    // Get child categories of current category

    $categories=get_categories($child_of);

     

    Apologies if I've explained myself badly

  3. I'm working on a custom category page for a Wordpress theme and I need to pass (correct me if that is the wrong terminology) to an argument for the function get_categories:

     

    if (is_category('4,6,9')) {

    ?>

     

    <?php $categories = get_categories("child_of=$cat-id");

     

    foreach ($categories as $cat) {

    query_posts("cat=$cat->cat_ID&showposts=-1&order=ASC&orderby=name");

     

    I would like $cat-id to be either 4, 6 or 9 depending on which category page the user is looking at. How do I make this happen?

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.