Wordpress categories taxonomy - wordpress

I`m using ACF plugin for custom fields and categories made from the plugin. My problem is that I made a custom category called "Mobile". Adding a new custom post and inserting it in the category "Mobile" from admin dashboard works.
But if i`m trying to to set the post to that category from code with wp_set_object_terms it gives me an error with invalid taxonomy. I have looked for a solution to my situation but the only thing that is important that the taxonomy to be loaded before i call it. I don`t know where to look in the ACF plugin or my plugin to see what`s wrong.
Can you give me an advice?
Thank you.

I think the problem is in the usage of wp_set_object_terms() function. The second parameter should contain the id or slug of the term to add, in your case, it should be the slug or the id related to 'mobile_cat'. Then the third parameter should specify the taxonomy where to add this term. In your post still don't know what is your taxonomy name.
You can get all the required info from database.
good luck

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 Custom Post Logic

I'm a newbie here, but I've been trying to understand and research this for the past couple of days to no avail.
I created a custom post type (video) with a taxonomy associated with it (industries). The taxonomy "industries" has multiple categories (I'm not sure if in this case they are called terms rather than categories; correct me if I'm wrong!) such as IT, Construction, etc. For arguments sake, let's say under the category IT there is a single post named Web Developer.
First question: With the logic above, how would I manage to reach the single post (web developer) with the URL: .../video/IT/web developer?
Second question: If on the video page I would like to display all posts in all categories, what template page should I create? Is it archive-video.php? The same question goes for the category (IT in this case): Which template page should I create in order to display all posts under a specific category?
I'll answer your second question first:
Yes, the template you should use for displaying all the custom post types would be the CPT archive, so archive-video.php sounds right.
For the categories (the exact way to say it would be "taxonomy terms" indeed), you would use taxonomy-{taxonomy}.php or even taxonomy-{taxonomy}-{term}.php if you need to get more specific.
About your first question, there is currently no core functionality to use custom taxonomies in your permalinks, but this might help you.

WordPress custom post type category order

I'm looking for a way to manually reorder the category list for custom post types,
are there any plug-ins that already do this?
I can probably code my own, but I'm not sure where to start, can you add custom fields to the categories that can be used to order them?
Anything to point me in the right direction would be great!
EDIT [resolved]
After a bit more digging I uncovered this:
http://wordpress.org/support/topic/plugin-my-category-order-custom-taxonomy-order-and-code-improvements
Which linked to this:
http://snipplr.com/view/48599/mycategoryorder-custom-taxonomy-mod/
and once you change line 51 to you custom taxonomy type it works like a charm, eg:
$tax = ($_GET['mytax'])? $_GET['mytax'] : 'category';
becomes
$tax = ($_GET['mytax'])? $_GET['mytax'] : 'my_custom_taxonomy';
works perfectly with 'Types' plugin linked by #Ajay Patel, cheers.
Not able to get you question perfectly.
But use this plugin Types - Custom Fields and Custom Post Types Management
Types makes it easy to customize the WordPress admin. Define your own content using custom post types and custom taxonomy. Redesign editing screens using custom fields.

Display Post Type taxonomy categories

im really struggling to find clear documentation on the following subject.
I have created a custom post type called 'file'.
List item I've also created a taxonomy called 'file_category'
From the WordPress Admin i've created categories: Configs, Media, Demos, SourceTV
I have a page using a template to display a list of all the 'file' posts.
I want to then display a list of the categories so users can filter the 'file' results.
Thank you in advance for taking the time to post your replies!!!
Technically speaking, those "file_category" categories you created are called "Terms", so if you want to edit your template file to show the "file_category" terms for each post, you would use get_the_terms() inside the loop. Documentation is here: http://codex.wordpress.org/Function_Reference/get_the_terms
To show all terms in a taxonomy (like the list of terms you mentioned you wanted to display) use http://codex.wordpress.org/Function_Reference/get_terms

Wordpress additional fields

In my WP installation I have a category called "books". In addition to the title and body text I'd like to add a field called "ISBN" that must be filled in for every post in this category. In the Blog category this field should not be displayed in the admin.
In Expression Engine and Drupal it's quite straightforward to add fields like this but I'm not sure about how this works in WP. What's the best way of doing this in WP 3.2.1?
In wordpress this can be done by adding meta-data to posts
http://codex.wordpress.org/Custom_Fields

Resources