• Resolved Granit

    (@granit)


    I have this Most Recent Posts part in my template.
    Now i need to exclude some categorys in this part, but i dont know how to do it.

    The part that controlls this looks like this,

    <div style="float:left;width:463px;">
    				<h2 class="img_title h2"><span><?php echo OnePanelLanguage::GetText( 'most_recent' ); ?></span></h2>
    				<ul>
    					<?php while (have_posts()) : the_post(); ?>

    I have tryed to use this before “while” query_posts(‘cat=-7’); that works, but the problems is that i have chosen to show 4 posts, and then when clicking to get to the next page of posts then the same posts appear.

    So does anyone know how to fix this?

    Thanks

Viewing 15 replies - 1 through 15 (of 17 total)
  • Try this with query_posts:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=-7&amp;paged=$paged");

    This is a poorly documented part of wordpress – you need to pass a variable to control the paging, or you get stuck on page 1.

    That should be a regular ampersand in there – the forum editor converted it into an entity

    Thread Starter Granit

    (@granit)

    That should be a regular ampersand in there – the forum editor converted it into an entity

    I am not sure i follow you here?

    Thread Starter Granit

    (@granit)

    I tryed the code you provided here and still getting the same result.

    Thread Starter Granit

    (@granit)

    Does anyone know how to fix this issue and get the code to work?

    Chris_K

    (@handysolo)

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=-7&amp;paged=$paged");

    see the &amp; in the second line? Change that to a normal ampersand (&) — this forum’s code editor is translating it for some odd reason.

    Thread Starter Granit

    (@granit)

    Yes i have done that but it does not work anyway with the pagnation or what it is called.

    I still get the same posts on every page.

    Thread Starter Granit

    (@granit)

    Why are you deleting my post all the time?

    If no one can help me here, does anyone know where to turn with this issue?

    Hi Granit – the code I posted was just a snippet to address what sounded like the key problem. Can you show me how you incorporated my code into yours?

    Thread Starter Granit

    (@granit)

    I have done like this, i am not that good when it comes to this and put the code where i tough it should be.

    <div style="float:left;width:463px;">
    				<h2 class="img_title h2"><span><?php echo OnePanelLanguage::GetText( 'most_recent' ); ?></span></h2>
    				<ul>
    					<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=-7&amp;;paged=$paged"); while (have_posts()) : the_post(); ?>
    Thread Starter Granit

    (@granit)

    toppa, if you need to see the while file please let me know because i really don´t follow you regarding this code you presented.

    MichaelH

    (@michaelh)

    If necessary, post the whole template (all the code) in a pastebin and report the link back here.

    Thread Starter Granit

    (@granit)

    Here the file is, i don´t know if there are any needs for the other files since to my knowledge it is in this file this is controlled.

    http://pastebin.com/m4985da9f

    Thread Starter Granit

    (@granit)

    Sorry for all of my post, but this is really frustration that no one can help out on this. I really tough that there would be some expertise here that would know a little bit of wordpress code.

    And since i don´t have any place to turn to this was my last option.

    I would be very glade is someone could point me in the direction of a place where one could get some support on this mater.

    And i hope that the moderator don´t delete my post.

    Your pastebin code looks mostly fine to me – you’ve correctly put the query_posts call before the Loop. I think it’s just a small typo causing the problem – you’ve got an extra semicolon after the ampersand (right before paged=$paged). Sorry, I would simply put the correct line here, but the forum editor would just muck with my ampersand again.

    Also, I’d recommend less agitation in how you’re phrasing your requests here. Most folks in the forums (like me) aren’t getting paid to be here. I’ve actually just recently begun helping out. It’s one thing to get agitated if you’re paying for support; it’s another when people are here making a community effort.

Viewing 15 replies - 1 through 15 (of 17 total)

The topic ‘Exclude Categories’ is closed to new replies.