Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Thanks for replying but I still can't get it to work. Is anything wrong with this code?

   <?php

class custom_loop extends thesis_custom_loop {
function page() {
if(is_page( array('career-work','happiness'))) {
      global $thesis_design;
$thesis_design->home['body']['content']['features'] = 0;
$thesis_design->display['archives']['style'] = 'teasers';
$thesis_design->image['thumb']['y'] = 'after-headline';
$thesis_design->teasers['options']['date']['show'] = 0;
$thesis_design->teasers['options']['excerpt']['show'] = 1;  
    global $wp_query;
    $saved_query = $wp_query;
    thesis_loop::page();
    wp_reset_query();
    $args = array('category_in' => array(59,'62));
    $loop = query_posts("cat=59,62");
    thesis_loop::home();
    wp_reset_query();
    $wp_query = $saved_query;
} else
    thesis_loop::page();
}
}
$custom_loop = new custom_loop();

The code above is to show teasers on a specific page. It obviously works for one page but where do I add this code, or what do I change it to, in order for it to work for any page I specify?

I've tried creating a new PHP file in my theme and copying and pasting the code (changing the category ID etc) but it won't work.

Thanks

share|improve this question
    
I can't really follow what you're trying to do here. You've pasted your code, which is good; but it needs context. Can you explain, in human terms, what you're trying to accomplish? Are you trying to output content conditionally on specific pages? If so, where are you defining your custom function, and where are you outputting that custom function? –  Chip Bennett Feb 21 '12 at 14:34
add comment

2 Answers

You are missing ' in your if statement. Then it should work, and you can use comma to specify various IDs or slugs for pages.

if(is_page('health-fitness')) {

Try this.

share|improve this answer
    
Thanks for replying but I stil can't get it to work. I edited the code above (as a new user I can't reply to my own question). Do you see anything wrong with it? –  Nick Feb 21 '12 at 14:06
add comment

One problem is your is_page() syntax:

<?php
if(is_page('career-work','health-fitness'))
?>

The is_page() conditional can only take one parameter. If you need to pass multiple values to the conditional, they must be wrapped in an array, e.g.:

<?php
if( is_page( array( 'career-work','health-fitness' ) ) )
?>

I don't know if that will completely solve your problem, but it is definitely one issue.

share|improve this answer
    
Thanks I'm almost there... I added the code you gave me, but as you would expect the code specifies to pull the content from both slugs and categories instead of having different content on different pages. I changed the code again at the top btw. –  Nick Feb 21 '12 at 16:09
    
I'm not sure you totally understand how is_page() works. The is_page() template tag doesn't "pull content" from anything; it's simply a conditional (i.e. Boolean) tag, that returns true or false, based on an evaluation of the current context against the $page parameter passed to it. –  Chip Bennett Feb 21 '12 at 16:12
    
I've been trying for hours to try and sort this out but no luck. Can anyone please help me? All I want to do is display teasers from the post content from certain categories which I can then display onto any page I specify. It sounds as if it would be quite a common question and easy to rectify but I can't find anything on the internet to help. –  Nick Feb 22 '12 at 18:21
    
How do you define the teasers? How do you determine/define the category/categories of posts for which to return teasers? How do you determine on which static Pages, which teasers to display? –  Chip Bennett Feb 22 '12 at 19:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.