Forums

[resolved] Exclude Categories (18 posts)

  1. Granit
    Member
    Posted 7 months ago #

    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

  2. toppa
    Member
    Posted 7 months ago #

    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.

  3. toppa
    Member
    Posted 7 months ago #

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

  4. Granit
    Member
    Posted 7 months ago #

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

    I am not sure i follow you here?

  5. Granit
    Member
    Posted 7 months ago #

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

  6. Granit
    Member
    Posted 7 months ago #

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

  7. Chris_K
    Administrator
    Posted 7 months ago #

    $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.

  8. Granit
    Member
    Posted 7 months ago #

    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.

  9. Granit
    Member
    Posted 7 months ago #

    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?

  10. toppa
    Member
    Posted 7 months ago #

    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?

  11. Granit
    Member
    Posted 7 months ago #

    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(); ?>
  12. Granit
    Member
    Posted 7 months ago #

    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.

  13. MichaelH
    moderator
    Posted 7 months ago #

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

  14. Granit
    Member
    Posted 7 months ago #

    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

  15. Granit
    Member
    Posted 7 months ago #

    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.

  16. toppa
    Member
    Posted 7 months ago #

    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.

  17. Chris_K
    Administrator
    Posted 7 months ago #

    excuse the small digression:

    Most folks in the forums (like me) aren't getting paid to be here.

    Well said.
    To my knowledge, nobody is paid to be here. We're all freely volunteering our time.

    @Granit -- you're welcome to hire support if the volunteer support makes you unhappy. Try the WordPress Jobs or the WP-Pro's mailing list.

  18. Granit
    Member
    Posted 7 months ago #

    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.

    Thank you so very much for that, now it works like it should and i huge stone is lifted from my head.

    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.
    _________________________
    Well said.
    To my knowledge, nobody is paid to be here. We're all freely volunteering our time.

    I am sorry if i have offended someone, and it was not my intention to offend anyone and i see you point.

    But this almost killed me and i am sorry for again.

    If i need any more help down the road i will keep the tone down and i totally see your point in this.

    I also hope to learn wordpress my self both for me own satisfaction, but also in order to help other.

    And again, thank you so much for the help.

Reply

You must log in to post.

About this Topic

Tags

No tags yet.