• Hi,

    I added the following to my header.php file:

    <?php query_posts('showposts=1&cat=11'); ?><?php while (have_posts()) : the_post(); ?>
    <?php the_title('<span style="font-weight:bold"><a href="?cat=11" style="color:#666">', '</a></span>'); ?><p style="padding:0px 20px 0px 20px"><?php the_content_rss('', TRUE, '', 30); ?>
    <?php endwhile;?>

    I had hoped it would just display ONE post in that one area(which it does), but then instead of displaying the rest of my page content in the main body, it just shows the same bit of text from my post.

    It seems to set query_posts for the remainder of my page to what I use in that bit of code, so no matter what page it’s on, it’ll look to cat=11 and show the most recent post, instead of the page content for that ID ??

    How do I fix this so it’ll keep the rest of my page content as it should be?

Viewing 15 replies - 1 through 15 (of 17 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Don’t use query_posts. Create a new query instead of modifying the default one.

    query_posts is only meant to be used for the MAIN query on the page. Not for every single query you want to make.

    <?php
    $myquery = new WP_Query('showposts=1&cat=11');
    while ($myquery->have_posts()) : $myquery->the_post();
    the_title('<span style="font-weight:bold"><a href="?cat=11" style="color:#666">', '</a></span>');
    ?><p style="padding:0px 20px 0px 20px"><?php
    the_content_rss('', TRUE, '', 30);
    ?></p><?php
    endwhile;
    ?>
    Thread Starter sincewelastspoke

    (@sincewelastspoke)

    That’s it 99% fixed.

    When on the Home Page it displays the_content_rss part, except on every other page.php part, it doesn’t display anything there ?? Why is this?

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Errr.. what? That really doesn’t make any sense. There’s nothing special about the_content_rss.

    If it’s not displaying, then you did something else wrong there. I just copy and pasted your code, then modified it to be a separate Loop instead of the main one.

    Thread Starter sincewelastspoke

    (@sincewelastspoke)

    Apologies. It made no sense.

    On most pages(index.php,archive.php etc.), the_content_rss part of your script IS displayed.

    However, on some(page.php) the_content_rss IS NOT displayed.

    Why can page.php not display that part?

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Hey, no idea. If it’s not showing on some pages, then those pages are running different code. I can’t debug what I can’t see.

    There’s no reason for the_content_rss to show nothing unless the_content_rss is not actually there for those pages. I’d try to work out what the difference is between them.

    Thread Starter sincewelastspoke

    (@sincewelastspoke)

    What do you need me to post?

    The difference seems to be that the only ones not showing ‘the_content_rss’ for that script, are coming from page.php.

    The contents of ‘page.php’?

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    No, that probably would not help me. I’d still only be seeing part of the picture.

    What you need to do is look at what the differences are between the pages where it does show and the pages where it does not. That secondary Loop, as written, will work anywhere, on any page. If it’s not working somewhere, then that Loop is either not there or not complete.

    Thread Starter sincewelastspoke

    (@sincewelastspoke)

    OK. I will be back shortly. Thanks so far, you’ve been a great help.

    Thread Starter sincewelastspoke

    (@sincewelastspoke)

    I’m looking at the differences between my ‘archive.php’ and ‘page.php’ but seeing very little.
    Could you possibly take a look if I email them to you? Understand it’s going beyond the call of duty, but this would be incredibly helpful.

    Thread Starter sincewelastspoke

    (@sincewelastspoke)

    I also tried changing the theme.

    I moved your code into the ‘header.php’ of an untouched ‘classic’ theme, and the same error occurs. the_content_rss displays fine except on those like ?page_id=5.

    So it it the script, the page.php file or is it putting your script in the header.php that is the problem?

    Thread Starter sincewelastspoke

    (@sincewelastspoke)

    Anyone have any thoughts?

    Like I said, I tried it on the ‘classic’ theme that I haven’t modified, and it still doesn’t display the_content_rss on any “page.php” page.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    How about just the_content()?

    I don’t know the_content_rss() that well, but I can’t explain your issue. It should work (and does for me) so beyond that, I’m at a loss. Maybe you have some plugin interfering or some such thing?

    Thread Starter sincewelastspoke

    (@sincewelastspoke)

    I’m afraid changing ‘the_content_rss’ to ‘the_content’ didn’t work either.
    What a strange error ??

    Here’s my (activated) plugins…

    Akismet 2.1.3
    Contact Form ][ 2.0.13
    Get-a-Post R1.4
    Multi-page Toolkit 1.0
    Pagebar2 2.16
    Search Everything 4.2.2
    SEO Slugs 1.0
    wp-cache 2.1.2
    WP-PageNavi 2.20
    ZenphotoPress 1.3
    ZenPhoto Single Sign-On

    Would it help at all if I sent you my ‘header.php’,’archive.php’ and ‘page.php'(edited) ?

    Can you replicate it at your end and see the results?

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Okay then, how about echo get_the_content();? Or echo $post->post_content;?

    The content has got to be there somewhere.

    Thread Starter sincewelastspoke

    (@sincewelastspoke)

    You beauty!!!!

    get_the_content(); did the job!!!!

    Now I just need to snippet it ?? ??

    You’re a legend Otto. Patience and Persistence. Many thanks!!!!

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Displaying ONE post on ANY page?’ is closed to new replies.