Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • artsaround

    (@artsaround)

    Hey poil11,

    I keep running into a problem using timthumb and I’d be interested to know how you solved it. As far as I can tell timthumb balks at accepting a complete url as the img src

    for example in a small test file I can get this to work:
    <img src=”timthumb.php?src=/wp-content/themes/ebc/no-image.gif&w=100&h=100&zc=1″ alt=”” />

    but not this:
    <img src=”timthumb.php?src=http://www.blahblah.com/wordpress/wp-content/themes/ebc/no-image.gif&w=100&h=100&zc=1″ alt=”” />

    Your functions.php script however passes a full url when it echo’s. Any suggestions, this has me stumped!

    Cheers

    Hi, I’m not sure what I changed but I have it working. I got to thinking though, what I’d really like to be able to do is modify the custom field restrictions on the fly instead of hard coding them into the page template.

    Here’s what I have right now:

    <?php
    	 $restriction1 = 'geographic_area';
    	 $restriction2 = 'species';
    	 $restriction3 = 'donor';
    
    	 $value1 = 'India';
    	 $value2 = 'Calisaya';
    	 $value3 = 'India Museum';
    
    	 $querystr = "
    		SELECT * FROM $wpdb->posts
    		LEFT JOIN $wpdb->postmeta AS $restriction1 ON(
    		$wpdb->posts.ID = $restriction1.post_id
    		AND $restriction1.meta_key = '$restriction1'
    		)
    		LEFT JOIN $wpdb->postmeta AS $restriction2 ON(
    		$wpdb->posts.ID = $restriction2.post_id
    		AND $restriction2.meta_key = '$restriction2'
    		)
    		LEFT JOIN $wpdb->postmeta AS $restriction3 ON(
    		$wpdb->posts.ID = $restriction3.post_id
    		AND $restriction3.meta_key = '$restriction3'
    		)
    		WHERE $wpdb->posts.post_status = 'publish'
    		AND $restriction1.meta_value = '$value1'
    		AND $restriction2.meta_value = '$value2'
    		AND $restriction3.meta_value = '$value3'
    		ORDER BY species.meta_value ASC
    	 	";
    
    	 $pageposts = $wpdb->get_results($querystr, OBJECT);
    
    	?>

    Here’s what I was thinking. You create a page, linked to a page template with a standard loop and then following that, the querystr following Dan’s example above. Instead of coding the restrictions into the template the template gets those values from the metadata associated with the newly created page.

    So each page would have 6 custom fields (restriction_key_1, restriction_value_1, etc) that would link into the following:

    $restriction1 = 'restriction_key_1';
    	 $restriction2 = 'restriction_key_2';
    	 $restriction3 = 'restriction_key_2';
    
    	 $value1 = 'restriction_value_1';
    	 $value2 = 'restriction_value_2';
    	 $value3 = 'restriction_value_3';

    The only problem is I’m not sure how to call those metadata fields from the post and insert them into place.

    Does anyone have an idea?

    If anyone stumbles across this post the following code, which is a slight modification of danbutcher’s original from this forum post works well for me.

    <?php
    	 $restriction1 = 'geographic_area';
    	 $restriction2 = 'species';
    	 $restriction3 = 'donor';
    
    	 $value1 = 'India';
    	 $value2 = 'Calisaya';
    	 $value3 = 'India Museum';
    
    	 $querystr = "
    		SELECT * FROM $wpdb->posts
    		LEFT JOIN $wpdb->postmeta AS $restriction1 ON(
    		$wpdb->posts.ID = $restriction1.post_id
    		AND $restriction1.meta_key = '$restriction1'
    		)
    		LEFT JOIN $wpdb->postmeta AS $restriction2 ON(
    		$wpdb->posts.ID = $restriction2.post_id
    		AND $restriction2.meta_key = '$restriction2'
    		)
    		LEFT JOIN $wpdb->postmeta AS $restriction3 ON(
    		$wpdb->posts.ID = $restriction3.post_id
    		AND $restriction3.meta_key = '$restriction3'
    		)
    		WHERE $wpdb->posts.post_status = 'publish'
    		AND $restriction1.meta_value = '$value1'
    		AND $restriction2.meta_value = '$value2'
    		AND $restriction3.meta_value = '$value3'
    		ORDER BY species.meta_value ASC
    	 	";
    
    	 $pageposts = $wpdb->get_results($querystr, OBJECT);
    
    	?>

    Hi Dan,

    Thanks for your code snippet, I think it’s what I’m looking for. I’m trying to restrict and then order a number of posts that have metadata for species and genus. I tried replacing all the word ‘term’ with ‘species’ and ‘course’ with ‘genus’ in your script. However I can’t get the generated page to display and records. Any idea what I could be doing wrong? Seems like it should be pretty clear cut.

    In my example I would restrict the results to a certain species (ie your summer) and then order by genus (ie your course).

    Cheers!

    Were you ever able to come up with a solution to this problem, I have the exact same one. I tried MichaelH’s approach, and although the page compiles I don’t get any results returned.

Viewing 5 replies - 1 through 5 (of 5 total)