• Resolved Cathy Mitchell

    (@multitalentedmommy)


    I would like to show ads (in javascript)in the post-content, only when it is not called in the index template. The codex mentioned <? if (is_home())– but says that it is deprecated now. what has replaced it?

    Also, I think I will run into a problem with where to place that snippet, as the post content is already in a query for (is_search()). Can this be done, and where would i place it?

    <?php
    	if (is_search())
    	{
    		the_excerpt();
    	}
    else		the_content();
    
    	?>

    I have tried everything else, even making my own post-content-ad division class in css, and that has gotten teh text wrapped around the ad the way I intended. But the ads are showing up on the index.php, which is not cool! ??

    thanks everyone,
    Cathy

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Cathy Mitchell

    (@multitalentedmommy)

    it would also work, if I could just get it to show up in “the-content()”, and not the excerpts. I’m thinking that must be possible… just not for me! any help?

    only when it is not called in the index template.

    Then don’t put it in the index ??

    Thread Starter Cathy Mitchell

    (@multitalentedmommy)

    ok – that totally gave me pause! lol, yes, I have indeed checked the index.php, but it(the index) calls the post.php just as it(the index) calls the header, footer, etc. So, I was thinking that I need to then edit the post.php, no?

    The post.php adds things like the meta data, link_pages, the_content/ the_excerpt, footer, and separater for each post. It is one of the simplest themes I’ve found (in the backend) which is why I’ve chosen to modify it. So, if it is the post.php that I must edit, the above question applies I think.

    Oh, that’s crap ??
    I hate those themes that have a post.php or loop.php – they go against the whole idea of customizing themes and template files.
    The rationale behind having different template files (like index, archive, search, page, category etc.) is that you can have very different Loops and queries + you can do all that stuff you wanted to do very easily: modifying the proper template file. However is making a theme that takes away that flexibility – is an idiot. (You can quote me on this…)

    Thread Starter Cathy Mitchell

    (@multitalentedmommy)

    Thanks for the info – I did try to delete the call to the post template, and input the direct loop (from the post template) and it worked great! Now the index.php has its own call to the loop.

    And my ads look great on the single & page templates…. And I just realized that I have to create the same “real” loop on every page where excerpts are used… hopefully not too many more! Categories, search results I think.

    wahoo, feels good to find a solution!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Need if-else snippet for post-content on index.php’ is closed to new replies.