jcpeden
-
Posts
5 -
Joined
-
Last visited
Never
Posts posted by jcpeden
-
-
I've tried both:
$dir = 'http://localhost/badsexsucks/wp-content/themes/AskIt/images/gay/';
$dir = '../images/gay/'
So, if I can't use a web address with glob, should the relative link work? Here is an image to show you the file structure. The file running this function is entry.php and is located in includes.
-
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:
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/'
-
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
-
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?
Count files in a directory always returns 0
in PHP Coding Help
Posted
Thanks I didn't know that! I was able to get the code working by figuring out the working directory using getcwd:
http://php.net/manual/en/function.getcwd.php