Category Listing Page with posts filtered to selected tag on Wordpress Blog - wordpress

I'm working on a Wordpress 3.4 project. I have categories and then several tags, and also one custom taxonomy as types.
Wordpress is fantastic as far as it handles all the taxonomy page, but I'm unable to figure out how to have pages where I have categories listing page (with pagination) specifically filtered to a selected tag or custom taxonomy.
So basically I want Categories, but then again, I also need to have a categories page with all posts filtered to specific tag, and then with pagination.
I have tried to figure out how to do that, but unable to find the exact doc or help. The issue is also with the URL, as how it will be formed?
Any idea how to fix that one, or any plugin to get this things done?

I think these two codex pages will help you along your way.
http://codex.wordpress.org/Class_Reference/WP_Query
and
http://codex.wordpress.org/images/1/18/Template_Hierarchy.png
You can use WP_Query to query posts based on tags and categories/custom taxonomies and much more.
If you look at the template hierarchy you'll see you can use special template files for tags and taxonomies too. Just remember to flush your permalinks if you're not seeing these templates being used if you create one.

Related

How to access an ACF field on a category from within pre_get_posts in functions.php to modify archive query

Long title, but what I'm trying to accomplish is
1) Adding a Post Object field to the Add/Edit Category page to specify a single post to use as a featured/sticky post for that category. As far as I can tell there's no way to do this (featured category post). Have used https://wordpress.org/plugins/category-sticky-post/ in the past but seems dead and starting to act buggy.
2) Display that post on top of the respective archive page 1, and then start with the normal loop for that category. This is working perfectly.
3) Where I'm stuck is how to exclude that featured post from the query so we don't get duplicates. I'm trying to do this in a pre_get_posts function in functions.php to modify the query so it functions like a normal archive page otherwise.
If you know of an easier way to simply set a featured article for a category I'm open to suggestions. I know sticky for main homepage loop but nothing for archive pages.
You may need more info but that should be a good starting point. Using ACF Pro (latest)
Thanks for the help!
You can use the ignore_sticky_posts property while querying posts using WP_Query to exclude the sticky/featured posts.
Reference: WP_Query

Wordpress - Show parent category AND subcategory name in subcategory archive URL

I'm having some trouble with Wordpress category/subcategory archive URLs.
For example, I want to be able to display this archive: http://faroutmagazine.co.uk/wp/track-of-the-day while keeping its parent category in the URL, making it http://faroutmagazine.co.uk/wp/music/track-of-the-day
Previously, I was just getting a "This is embarrassing..." 404 message when accessing the /music/track-of-the-day URL (even though that's the one that was appearing in the View option under categories in the admin section of WP).
Now the View link in the admin area only shows me the /track-of-the-day URL, and this DOES display the category posts which is great, but I want it to include the parent category in the URL.
Is there anything I can do to the functions.php file or any plugins I can add to make this happen? Please bear in mind that there are multiple subcategory archives on this site, and they should all contain the parent category in the URL.
***UPDATE:
I actually have just set everything up a different way now using Pages and showing category archives on pages as it's taking up too much time. Thanks for your answer though. People telling me to use %category%/%postname% as the permalink structure are incorrect - yes, this works for the POST urls but not for the archive category of the subcategory which is the problem I was actually looking for help with. If anyone can provide an answer, it would be appreciated, but I am using this workaround now as this was taking up way too much time trying to figure out.
This happens because you chose category and subcategory from the right options tick boxes when editing the entry. Choose only the subcategory box in every entry and it will show the nested URL.
To make this happen you need to make some change in permalinks
go to Settings->Permalinks then select custom structure and use this syntax " /%category%/%postname%/ "in the field
Now save the settings and you can see the post url's using its category name in the permalink
Hope it helps :)
You should set hierarchical value to true when you are defining your taxonomy.
'rewrite' => array('slug' => 'mySlug', 'hierarchical' => true),
Then if you have a subcategory the url will be shown like this:
http://example.com/taxonomy/parentCategory/subCategory/
I found this sloution here:
https://wordpress.stackexchange.com/questions/155319/how-to-include-parent-terms-in-hierarchical-taxonomy-urls
Actually hierarchical subcategory archive permalinks are default in wordpress.
If you have a "pretty permalinks" structure selected in settings > permalinks, like /%postname% for example, then category and subcategory archive urls should default to something like:
yourdomain.com/category-base/category/sub-category/sub-sub-category
I had encountered a similar issue with a recent WP project, BUT I was using a plugin called WP No Base Permalink in order to get rid of my category and tag base slugs in my archive permalinks. When I deactivated the plugin, category hierarchy suddenly returned to my archive permalinks (luckily this project was still in development, otherwise, I would have had some major 404 problems).
I have not yet found/tested another plugin for eliminating category/tag base slugs that will also preserve hierarchy in sub/category archive urls, but it turns out that I do not need that functionality for my current project.
Instead I am using the base slugs blog-articles and blog-tags for the standard categories and tags in order to set the blog taxonomies apart from other taxonomies. Then I am using the plugin Types to create a custom post type and custom taxonomies for that post type. The Types plugin has an option in the advanced settings to set hierarchical taxonomy urls to true or false when creating a custom taxonomy.
Finally, I found a plugin called Remove Taxonomy Base Slug that effectively eliminates the default taxonomy term from the base slug of the taxonomy archive urls. And this, thankfully, does not interfere with the hierarchical sub/category urls, OR the base slugs for standard tags and categories.
So now, my blog categories/tags look like this:
yourdomain.com/blog-articles/category/sub-category/
or yourdomain.com/blog-tags/tag/
And my custom post type categories/tags look like this:
yourdomain.com/category/sub-category/ or yourdomain.com/tag/
Phew!
I hope this helps!
Setting Settings->Permalinks->Category base to '%category%' should give you what you want. According to WP doc:
Nested sub-categories appear as nested directories in the URI
See http://codex.wordpress.org/Using_Permalinks.
The Permalinks settings should be like /%category%/%postname%/ ..
If use custom permalinks settings as %postname% only, it will make your url in the form of .../category/subcategory.
You can use WordPress plugin to remove 'category' from url
http://wordpress.org/plugins/wp-no-category-base/
and then follow the instruction given by Maruti

Excluding a single category from Wordpress all posts results

I'm looking for a bit of help as I struggle to create a page that has a list of all of my clients' products. Currently I'm using this URL, which works great (with a caveat): http://tayloryourevent.com/?p=*
(note: on her site, both products and blogs are created as posts, but in separate categories)
As you can see, all the products show up nicely, but also included in the mix are blog posts, which I need to hide from that page.
My real problem is that I'm confused by the /?p=* and what that's doing. Since it's a page being created on the fly, I don't know where to look to get a glimpse behind the scenes.
2 questions:
Where is the /?p=* getting its theme from? Could I copy that theme and edit it to exclude the blog category?
-or-
Could I exclude the blog category with some kind of fancy URL work?
This plugin should be able to exclude blog categories: Simply Exclude

Wordpress - Create a author.php, but only for a Custom Post Type

I wanted to create a new page similar to author.php in wordpress, but that lists only a specific Custom Post Type. It is important to have both pages: author.php for regular posts, and this new author-custom-post.php only for the Custom Post Type.
The usage is that the first one will list the blog posts, and the other one will list the author's cientific publications, each one in its own page.
And, of course, it should have a link to this author-custom-post.php that I can use in the author bio.
I could only manage to find pages listing both things together, but nothing about listing in different pages.
Thanks in advance!

Custom post-type child category archive

Having a bit of a headache with WordPress at the moment after days of searching for an answer. I have a custom post-type on a new site called videos, and I want series of videos on the site. I decided to use standard categories for organising these videos into the series.
So, my structure goes:
Videos (post-type) -> Series (Category) -> The Making Of (child-category).
In terms of the hierarchy I have no idea which template would allow me to show all the posts from the child category? I've tried so many variations and none seem to work. And yes, I've been looking at the template hierarchy.
Maybe I'm just missing the obvious, but does anyone know what template is needed to show this child-category? I'd hate to have to make a page each time there's a new series to show.
[UPDATE]
So, I've changed over to a custom taxonomy as suggested in the comment below. And I've managed to get the list of posts from my making-of category showing up in a list. This uses the taxonomy-$term.php template.
This shows in the url mysite.com/series/making-of/.
But, I'm struggling to find a way to display all of the different categories from the post-type on a single page. I thought it would use just the taxonomy.php file but that doesn't seem to work.
I thought the url would have been mysite.com/series/

Resources