Jump to content
Sign in to follow this  
mcburkhead

New to using Hooks, what am I doing wrong?

Recommended Posts

mcburkhead

I am trying to only have 9 posts from only 1 post category show on the home page. This is what is in my functions.php add_action ('pagelines_before_theloop','less_posts'); function less_posts(){ if (is_home()) query_posts('posts_per_page=9');} add_action ('pagelines_before_theloop','only_articles'); function only_articles(){ if (is_home()) query_posts('cat=-6, -5');} It seems that only the second hook action 'only_articles' is working. Any ideas?

Share this post


Link to post
Share on other sites
Kate

Hey Matt, Basically both of these functions are doing the same thing, including checking if it's the home page. The only difference is the query_posts values. Try this: ` add_action ('pagelines_before_theloop','only_articles'); function only_articles(){ if (is_home()) query_posts('cat=-6, -5&posts_per_page=9');} `

Share this post


Link to post
Share on other sites
mcburkhead

Thanks Kate! Worked like a charm. I was trying all sorts of patterns but did not realize that "&" was how you can activate multiple actions in one hook. If I wanted to add a third, would I add another "&"? Thanks again for the help

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×