开发者

How to exclude posts in taxonomy based on custom field?

I have a custom post type called 'real-estate' and a bunch posts (listings) within it. What I'm trying to do is create a handful of home styles and within them, specific listings of available homes.

So right now, I have the search query pulling in only the home styles from the search by only showing results with the custom field "model" set as "true." However, when clicking this, I would like it to displ开发者_如何转开发ay specific homes which are apart of that style.

For example, a search query will yield Home Style A and Home Style B. When the user clicks Home Style A, it would show a general overview of the home style, with a link to an archive page of specific homes (i.e. 123 Fake St., 456 Made-up Lane) but omit the Home Style A from displaying within that query.

Right now I'm accomplishing this by creating a new taxonomy called "Home Styles" and categorizing them as such. I'm displaying only the model homes by querying only posts with that custom field I mentioned above. That part is working fine. However, when I click the link to display the rest of the homes in that taxonomy (/model-homes/model-home-a/) it shows all posts within that taxonomy, including the model home listing. Is there a way I can exclude the model homes from the taxonomy archive similar to the way I'm only including them in the search? I'm hoping theres a solution to make it dynamic by editing the taxonomy-home-style.php instead of doing it for each term in case new ones are added frequently.

Hopefully this makes sense, I've been trying to wrap my brain around the concept for hours now and trying to think of the best solution to accomplish this. Thanks.


Nevermind, figured this out on my own. I made it more complicated than it was. I used the method on this site to edit my taxonomy-model-home.php. Adding two lines of code and it works!

http://www.solo-technology.com/blog/2007/09/08/how-to-another-way-to-exclude-posts-from-the-front-page/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜