How to exclude posts in taxonomy based on custom field? - wordpress

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 display 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/

Related

Any Wordpress plugin to search posts by category?

I am developing a website for an auto dealer. On the homepage and maybe even in the sidebar I would like to place a search function which will allow the user to search for cars according to Make (e.g. BMW) and Model (e.g. 1 series). Then a page with results will show up. Users can either search by make only or both.
Is there a plugin or code that can do this?
Each Make will be a POST category and model either under parent category (daughter) or as a tag?
Have a look at: http://wpadvancedsearch.com/. It does exactly what you want.

Views and Categories...?

it's about this page: http://veagues.com/
Hey guys,
I've made a block-view with drupal that let's me sort my videos by a certain category, in this case "funny","epic","plays", "contest"...
The problem is: When you sort it by the certain category and click on a video and continue to click the "next" button, you will go threw all videos, instead of only the videos of the category...
My Question is: How can I put a filter on the nodes when i apply another category on the bottom block?
Thanks already!
If you're using Views, you should be able to filter the main block by the same taxonomy term.
Try adding a Contextual Filter to that block too. If there's a taxonomy term ID in the URL the block gets filtered by that Term ID and if there's no result, the block shows all the videos.
EDIT -----------------------------------------------------------------------------------------
You may need to try & understand what goes on when you make a selection in Drupal.
1/ The taxonomy term page will list all the content affixed with a specific term. The term tid can be seen in the URL, unless an alias have been created. A block can retrieve that term id, whether there is an alias or not.
2/ The node page will give you access to a specific node, but any block on that page should be able to access the term id of that specific node.
If you know where you are, it becomes easier to retrieve the info you're looking for. On the other hand, you may have to reconfigure a specific page in order to add the necessary extra block...
That can be done with templates but you could also have a look at Panels.
The Panels UI makes it easier to configure the page you're looking for without having to mess with code or templates, or both.
There's a lot of free video tutorials out there, search for Views & Panels.
If you want to have a look at preprocess functions, you will definitely need to download the Devel module...
...but have a look at these sites first:
http://codekarate.com/
http://drupalize.me/
http://buildamodule.com

Panels linking to articles or pages

New to Drupal. Installed it, set Bartik theme as default, created a few pages with a menu. Now I would like to do something like this:
where the pictures with descriptions link to either other pages or articles. Each of them should have custom size.
What is the simplest way to do it?
For the testing I have created 4 articles on my home page, but obviously they sit one on top of each other. The same happens when I add blocks.
There is not better option to this than to install and use Views module. You can achieve exactly what you want using the nice UI it provides.
You need Views if
You like the default front page view, but you find you want to sort it differently.
You like the default taxonomy/term view, but you find you want to sort it differently; for example, alphabetically.
You use /tracker, but you want to restrict it to posts of a certain type.
You like the idea of the 'article' module, but it doesn't display articles the way you like.
You want a way to display a block with the 5 most recent posts of some particular type.
You want to provide 'unread forum posts'.
You want a monthly archive similar to the typical Movable Type/Wordpress archives that displays a link to the in the form of "Month, YYYY (X)" where X is the number of posts that month, and displays them in a block. The links lead to a simple list of posts for that month.
P.S - Views module is the most used and installed module in Drupal, hence, it will be a part of Drupal 8 core.

Concrete5 Custom Content Types (Blocks)

Is there anywhere online where one can find how to create custom blocks in the same way we can create custom content types in Wordpress. The desired result is to add a block that will allow the user to add/edit custom fields like client name, portfolio description, portfolio thumbnail.
I've created a free tool called "Designer Content" that lets you easily generate these custom blocks:
http://www.concrete5.org/marketplace/addons/designer-content
That being said, it is important to understand this key concept: In Concrete5, everything revolves around PAGES. In general, you want to try to establish an architecture where each piece of data is represented on its own page (a "details" page, which would roughly equate to a single blog post in Wordpress). Then you use the Page List block (usually creating a custom template for it to modify its look) to list out titles, links, and excerpts/photos from each of those "details" pages on a top-level "index" page (roughly equivalant to the home page or category archive in Wordpress).
For example, if you're building a portfolio site, you might want one top-level "Portfolio" page that shows a thumbnail and title of each piece, then a "Portfolio Item Detail" page type that contains one piece per page -- each living underneath the top-level "portfolio" index page.
The benefits of this approach are C5 gives you out-of-the-box tools to manage your "data" (pages) in this way -- users can add, edit, delete, and rearrange the pages via the "Sitemap" in the dashboard. Site search works without any modification -- each page (i.e. portfolio piece) will be its own search result with a link to a specific page. Also you then have more fine-grained control over access permissions if you ever decide to restrict access to only certain groups of people (registered users, etc.).
If you take this approach, you might find the "Page List Teasers" addon helpful (it will let the Page List block -- which you're using for your top-level "index" page -- to show actual content excepts from the pages instead of just a separate "description" field):
http://www.concrete5.org/marketplace/addons/page-list-teasers
Or if you want to dive deeper and customize the page list template even more, I have a starting template with a ton of code comments in it explaining how to do different things here:
https://github.com/jordanlev/c5_clean_block_templates/blob/master/page_list/view.php
But... if you're only talking about small amounts of information and you think a separate page for each one is overkill, then the Designer Content approach I linked to first will work just fine.
You can find a HOW-TO on creating new blocks written by Franz Maruna on the concrete5 website.
Here is the link: Creating a New Block Type
There is also a simple block you can download and install to help you follow the developer tutorials. You can find that here: Simple block template

Post privacy in Wordpress

Can a post be hidden from home page, archive view, category lists etc. and viewable only if you have a direct link to it? The blog doesn't have registered readers and is open to public so that would be a mean of hiding some posts from public view without using the password protection.
I asked this question in Wordpress section and the idea there was to use conditional code so I'm asking the question here as well to get closer to the code.
If I used conditioning, would I have to input each post's ID separately to PHP file for archive, categories, search and such?
EDIT:
After reading a bit more all over, I had an idea of creating a private category and then use some kind of conditioning so that posts from that category are hidden. According to Codex, certain category can be hidden from, for example front page but I don't know if there's a way to hide it altogether except when you have a direct link.
Creating a "Private" category is a good solution. It is quite possible to hide this category altogether except via direct link. You just have to "block all the exits" with conditional code.
The default WordPress theme displays posts via the Post Loop. See http://codex.wordpress.org/The_Loop, especially the section entitled "Exclude Posts from Some Category". Just find all the places in your theme's PHP files (e.g. index.php) where this loop is used, and add the conditional code. You'd also need to filter your category list and blog archives in the side menu. Don't add filtering in single.php, otherwise the private post won't display on its own page.
You'd probably want to add a similar condition to filter search results so that private posts aren't leaked via the blog's search tool. There may be more "exits" I haven't thought of, but I'll be sure to update as I do. I'm glad to look at specific code if you so desire.
Understanding WordPress' post query and loop really opens up a world of possibilities for customization.
I found the simplest way - just use Simply Exclude Wordpress plugin. It has the option to exclude each post (or tag, for that matter) from front page, archive, search or feed. It works flawlessly. You can still view the posts by using direct links.
(Not actually an answer that includes code but a working solution nonetheless.)

Resources