Tag Info

New answers tagged

0

If you trace the code through the source, you will notice that the links are created by get_term_link() and that there is a filter in that function called term_link. The second parameter of that filter contain the object ID which, as near as I can tell, is only set if the tag is part of the current post. Leveraging that information: function ...


0

I was able to achieve this by following code: $allterms = get_terms( $taxonomy ); $pterms = get_the_terms( $post->ID, $taxonomy); $tag_list = implode(',', wp_list_pluck($pterms, 'term_id') ); $t = explode(',', $tag_list); echo '<div class="tag-cloud">'; foreach ($allterms as $term) { ...


0

In both your rewrite arguments, add 'with_front' => false, then for your taxonomy change 'slug' => 'topics' to 'slug' => 'knowledgebase'. Finally, switch the order of your registration - so that register_taxonomy is called first. This will place the taxonomy rewrite rules above the post type rules (otherwise the latter will catch the former, since ...


0

What are the terms and taxonomy in wordpress? From WordPress.org's Taxonomy Codex... In WordPress, a "taxonomy" is a grouping mechanism for some posts (or links or custom post types)... The names for the different groupings in a taxonomy are called terms. Using groupings of animals as an example, we might call one group "birds", and ...


0

You're registering your taxonomy only if is_admin is true, so your taxonomy won't exist for any non-admin request. Taxonomies (and post types) have to be registered on every request.


0

Normally usage of get_term() or get_term_by() is pretty much clear cut. See the basic example below: // ID is needed $term_by_id = get_term( 12345, 'destination' ); echo $term_by_id->count; // Or if you e.g. want use the name (or slug or id or term_taxonomy_id) $term_by_name = get_term_by( 'name', 'greece', 'destination' ); echo $term_by_name->count; ...


0

To get the portfolio category in the url you could possibly navigate to Settings > Permalinks and add a custom structure like so %category%/%postname% that will add the category before the postname.


1

Are you sure that you don't have a page with the same name of the custom post type? If you do, the permalink rewrite rules will get confused and trigger a 404. A very simple solution is: The page that lists the custom post types is called in plural (eg. products) and the actual post type name is in singular (eg. product). So they don't conflict and it's ...


0

I don't know what you need to do that. If you are creating a custom taxonomy you can just copy your archive.php content copy the whole php in it. Create a new file in your template called "taxonomy-yourcustomtaxonomyname.php" paste the code from archive.php you just copied, and WP will handle the rest :) you can learn more about custom templates for ...


0

So this is what I needed: <?php $terms = get_the_terms( $post->ID , 'board' ); foreach ( $terms as $term ) { echo $term->name; } ?>


0

Posts and Categories are tied together. Your best bet is creating custom post type that supports only your taxonomy. This way, your posts (which are now under your custom post type) will not have any conflict with wordpress assigning default category. If you explain your scenario with more details, I will be in better position to help you.


0

I had this same problem when I cloned my site to set up a development server - for me, it working by setting permalinks to ugly, saving, then setting them to pretty again, which rebuilt whatever had gone wrong in htaccess.


0

The name you are using for taxonomy isn't allowed. register_post_type() $taxonomy parameter says $taxonomy (string) (required) The name of the taxonomy. Name should only contain lowercase letters and the underscore character, and not be more than 32 characters long (database structure restriction). Default: None So, you need to change the ...


0

Ok I got it! That's the code for my search-results.php <?php include('../../../wp-load.php'); $term=$_GET["term"]; $json=array(); $terms = get_terms( 'produits' ); if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){ foreach ( $terms as $term ) { $json[]=array( 'value'=> $term->name ); } } echo ...


0

The problem was with exclude_from_search parameter when I registered the post type. exclude_from_search (boolean) (importance) Whether to exclude posts with this post type from front end search results. Default: value of the opposite of public argument 'true' - site/?s=search-term will not include posts of this post type. 'false' - ...


0

You should follow appropriate naming convention (aka Template Hierarchy) of your templates to make your job done. If I'm clear about your query here then I'd suggest you to name your custom taxonomy archive template(s) as "taxonomy-{your-taxonomy-name-here}.php" (i.e. taxonomy-vegetable.php, taxonomy-fruit.php and so on) There must not be any blank ...


0

Yep! After a lot of research I got plugin 'Custom Permalinks'. Which fulfils my requirement regards - custom URL e.g. for Category for Post for Custom Post for Custom Taxonomy etc. Like this Custom Post Type - Post:


0

iolocin, I took your edited answer and as Pieter Goosen mentioned, made sure it was an array in an array and as per the codex. Final working code: function wpse188669_pre_get_posts( $query ) { if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) { $tax_query = array( ...


3

The problem with your approach is that woocommerces product category is a custom taxonomy called product_cat. But with cat you are addressing the built-in category. Taxonomies can be addressed with a tax query, simplified example below: function wpse188669_pre_get_posts( $query ) { if ( ! is_admin() && ...


0

So to answear my own question after much googeling: In the args array I commented out the option for show_in_menu, so that custom post type creates the menu itself. Then I didn't add the admin menu, but just the submenu (the hook still remains). add_action('admin_menu','bsp_plugin_menu'); And the first parameter is the one that shows it in the menu ...


1

I would just just scrap the function above as there are several bugs in the code and is also not quite effecient. I am actually surpriced that it really works for you. Your best solution here would be to write a complete new function. Here is want we want to do and how we are going to accomplish this Get the current post object on the single post page. ...


0

So to achieve your 2 issues all we have to do is modify the $args array that is being used for the Query. Because this is a Query we can use any of the parameters that Wordpress has kindly provided for us here: WP_Query. Like this one: post__not_in (array) - use post ids. Specify post NOT to retrieve. And this one: posts_per_page (int) - number of post to ...


2

Drop your custom query and go back to the default loop. Never replace the main query on the home page or any kind of archive page with a custom query. Use pre_get_posts to alter the main query variables before the main query runs Your taxonomy archive page should look like this if ( have_posts() ) { while ( have_posts() ) { the_post(); ...


0

Seems I need to find the term id before displaying the field $terms = get_the_terms( get_the_ID(), 'album_category'); http://www.advancedcustomfields.com/resources/get-values-from-a-taxonomy-term/


0

It sounds to me like you want to get the most recent term from your issue_filter taxonomy. To do that you'd want to use get_terms() with a few arguments. $t = get_terms( 'issue_filter', array( 'orderby' => 'id', 'order' => 'DESC', 'number' => 1, 'fields' => 'ids' ) ); That should get you the most recently created term ...


0

Solved it just by using taxonomy-{taxonomy-name} in an array in the filter manage_{post-type}_posts_columns


0

I was having difficulty with the code provided by Alexufo, so I rewrote it based on the updated function in WP 4.1.2, Here's my updated drop_cat function: //function below re-purposed from wp-admin/includes/meta-boxes.php - post_categories_meta_box() function drop_cat( $post, $box ) { $defaults = array( 'taxonomy' => 'category' ); if ( ! isset( ...


0

I can't comment yet, but I would suggest first to modify your loop <?php // The Query $query = new WP_Query( $args ); // The Loop <?php if ( $query->have_posts() ) : ?> <?php while( $query->have_posts() ) : $query->the_post(); ?> <li><?php the_title(); ?> - <?php get_post_meta( get_the_ID() , ...


1

Your tax query should be an array of arrays. Important Note: tax_query takes an array of tax query arguments arrays (it takes an array of arrays). This construct allows you to query multiple taxonomies by using the relation parameter in the first (outer) array to describe the boolean relationship between the taxonomy arrays. ...


0

I figured out the answer, since I am registering my taxonomy as phototype I simply have to create a file named taxonomy-phototype.php and inside that I will get the data by looping like I normally would in wordpress <?php if (have_posts()): ?> <?php while (have_posts()) : the_post(); ?> <?php the_content(); ?> <?php ...


3

You have a syntax-ish error, or a spelling one. There is a space after "taxonomy" in your tax_query array. If that were the sum of it I'd have just posted a comment, but additionally that $query->tax_query->queries[] = $workspace_taxonomy_query; line is pointless. Nothing changes with or without it. Don't try to hack the array like that. Just use ...


0

Thanks Phil Hoyt, this was exactly what I was looking for. But, alas, I couldn't get it to work with my setup. What does work is the following: <?php // Solution for sorting by ACF custom-field for tracks categories // http://support.advancedcustomfields.com/forums/topic/sorting-categories-list-by-custom-field/ $categories = ...


0

Have tried flushing your permalinks? Trying going into your dashboard, then Settings -> Permalinks. And then just click save settings to flush your permalinks.


0

I personally would do a custom post type for photographs, and custom taxonomies for venues and seasons (or probably a hierarchical taxonomy that used venue and season in one). As for archives - archives.php (or archive-custompost.php) (or taxonomy-custom.php) are simply templates. You can add whatever you want to it. As for saving "page" data, you ...


0

I've got this fixed now. Managed to talk with my old developer and he added this: $termsById = array(); foreach ($terms as $t) { $termsById[$t->term_id] = $t; } I had to add this new variable where $terms was previously used on line 14. Thanks for your help everyone, I appreciate the effort.


0

You have lot of issues here; Never ever use query_posts, it breaks the main query and page functionalities. You are breaking and nullifying the main query even before query_posts can have a change to do it in this line $wp_query= null As this is a shortcode (taken from your comments) and with this line, 'posts_per_page' => $num,, I believe that you ...


0

I was trying the same thing to achieve this but finally i found a better solution here. It works with regular taxonomies (categories) and also work with custom taxonomies. You should check its code inside or can use it as it is if the requirements are the same.


0

Well, they say perseverance is the key... Having found a link in the RELATED questions.. http://stackoverflow.com/questions/17588525/how-to-join-post-meta-and-taxonomy-table-wpdb-mysql, I got the answer. Ok, its not using Native parameters as suggested, nor does it give excessive load times as thought (its only displaying 5 properties max in a sidebar ...


0

Just changed permalink settings ti default and then changed them to post_name and then it worked fine. page templates were created fine and taxonomy were registered fine as well. issue was with .htaccess file.


0

I think you are using brand taxonomy for the post type product. You should create a file taxonomy-brand.php in your theme directory to display whatever you want in this page. You need not to create page template with this name, only create a file with this name in your theme. If you create any page by name brand please rename or delete it because page ...


0

display by ID: if 'id' => 'my-meta-box-2', then ID, 'my-meta-box-2', true ); ?> if you are using the rwmb plugin view the resource to echo the plugin correctly.


-1

If I understood your question correctly: set your permalink structure as /%category%/%post%/ and from your mega menu create custom links for taxonomies categories and single posts.


2

I think you have misinterpreted custom post-types and custom taxonomies, somewhat. Theory Custom Post Types I consider the purpose of a custom post-type to be format of data distinct in it's own right - it describes a type of content, but not the content itself. Take the in-built page, post, and attachment post-types, for example: The page post-type ...


0

Based on the comments of @Milo and using the rewrite analyzer plugin I found what I understand as a conflict in the rewrite rules?. The following url: exams/high-school/city-name/subject/math/ matches the following rules Pattern: (.?.+?)/page/?([0-9]{1,})/?$ Subtitution: pagename: exams/high-school/city-name/subject/math paged: 1 Pattern: ...


0

This is going to be a ton of code and a ton of explanation. Most of which can be copy and paste but I suggest taking the time to understand what's going on and why. First thing to understand is that WordPress does not have Taxonomy Metadata but it may someday. This means that we need to save our data as options. Second thing to understand is that we have to ...


0

For your situation, ideal solution would be this plugin: Restrict Categories It allows you to restrict the users to add, view and edit categories. Note: But before installing, make sure you have a backup. The most recent review had a problem of categories getting disappeared.



Top 50 recent answers are included