Title: Modifying a weird loop?
Last modified: August 20, 2016

---

# Modifying a weird loop?

 *  [3Joe3](https://wordpress.org/support/users/3joe3/)
 * (@3joe3)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/modifying-a-weird-loop/)
 * Ok everyone, I have a loop that is absolutely NOT cooperating with me. I need
   to mod this loop to ONLY include a category called ‘bbin.’ I’ve scoured the internet
   trying to figure this out and I’ve found a bunch of code that SHOULD work, but
   I keep getting an endif error. Please help!
 * Here is the code:
 * _[Code moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome#Posting_Code).
   Please use the [pastebin](http://wordpress.pastebin.com/)]_

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/modifying-a-weird-loop/#post-2211434)
 * not knowing what you tried so far,
    try and add a line like this before your 
   loop:
 * `<?php $bbin = get_cat_ID('bbin'); query_posts( array('category__in' => array(
   $bbin), 'paged' => get_query_var('paged') ); ?>`
 * based on ‘bbin’ being the category name:
    [http://codex.wordpress.org/Function_Reference/get_cat_ID](http://codex.wordpress.org/Function_Reference/get_cat_ID)
 * [http://codex.wordpress.org/Function_Reference/query_posts](http://codex.wordpress.org/Function_Reference/query_posts)
 * [http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters](http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters)
 * (untested)
 * ps: the ‘endif error’ is probably caused by breaking the php syntax in some way.
   therefore, it would have helped if you posted at least one of the failed attempts.
 *  Thread Starter [3Joe3](https://wordpress.org/support/users/3joe3/)
 * (@3joe3)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/modifying-a-weird-loop/#post-2211436)
 * Ok, here is the original code again:
    _[Code moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome#Posting_Code).
   Please use the [pastebin](http://wordpress.pastebin.com/)]_
 * Here is where I’ve found the most information on modifying the loop (in case 
   you care to check it out):
 * [http://codex.wordpress.org/The_Loop#Multiple_Loops_in_Action](http://codex.wordpress.org/The_Loop#Multiple_Loops_in_Action)
 * This is the code I used from the link above, that I was hoping would work:
 * _[Code moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome#Posting_Code).
   Please use the [pastebin](http://wordpress.pastebin.com/)]_
 * And here is the error message I get:
 * > Parse error: syntax error, unexpected T_ENDIF in /home2/mountat5/public_html/
   > wp-content/themes/kelontongfree/home.php on line 84
 * This is line 84:
 * `endwhile; endif;`
 * Any ideas?

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Modifying a weird loop?’ is closed to new replies.

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)
 * [exlude](https://wordpress.org/support/topic-tag/exlude/)
 * [have_posts()](https://wordpress.org/support/topic-tag/have_posts/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)

 * 2 replies
 * 2 participants
 * Last reply from: [3Joe3](https://wordpress.org/support/users/3joe3/)
 * Last activity: [14 years, 10 months ago](https://wordpress.org/support/topic/modifying-a-weird-loop/#post-2211436)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
