Tag Info

New answers tagged

0

Since I'm not sure if you are using single.php for anything else, I am going to suggest that you copy single.php to single-14kgs.php in the theme directory. Once you have done that, modify the following: <?php next_posts_link(); ?> becomes... <?php next_post_link('%link','%title',TRUE) ?> and <?php previous_posts_link(); ?> ...


0

This will resolve your issue, I was having the same problem, when I put this it worked perfectly. $args = array( 'post_type' => 'mycustomtype', 'posts_per_page' => 12, 'orderby' => 'date', 'order' => 'DESC', 'post_status' => 'publish', 'tag' => 'mycustomtag', 'cat' => 'mycustomcategory' ); ...


0

It needed to be the following: 'category__in' => $categoriesIds, with 2 underscores instead of one.


0

Thanks to @shanebp, I have found the answer to the problem. When registering a CPT, the taxonomies by default "category" and "tag" are the same as the one from the regular post. It means that the template needed to display the category related items is only the regular category.php. Therefore, my mistake was to thing of something like category-project.php ...


0

When clicking on any of those links, redirecting to an URL like "root/category/post-name/", the 404 template is loaded, If you remove the category_template filter, are the links still 404? For categories, your cpt post should appear in the list of posts in that category. So the url is root/category/. When clicking on any of those cpt links, the ...


0

Use the save_post action hook and in the call back function use wp_set_object_terms( $object_id, $terms, $taxonomy, $append ) function. For your custom post type the code can be like this function save_book_meta( $post_id, $post, $update ) { $slug = 'book'; //Slug of CPT // If this isn't a 'book' post, don't update it. if ( $slug != ...


0

I too struggled immensely trying to use subdomains for categories on my wordpress site. I tried a variety of plugins that were very buggy and eventually attempted writing my own. I kept running into additional problems left and right. Frequently I'd add new plugins that didn't function properly with the unconventional subdomain setup and I ultimately gave up ...


0

Yes, you can. The Function to help you out here is get_term(). The return of this function delivers you a value for parent. Using this ID, you can get the Parent Taxonomy (as long as it is hierarchical like the categories). Attention To get this function to work correctly, you have to select JUST the bottom category for your post, for example "South ...


0

"Category" is a taxonomy. What you're looking to do is limit the number of "terms" Depending on your goal (I think you want to show comingled attachments and posts in one giant list/interface?) - what you could do is create a new taxonomy, call my_attachment_terms and then add terms to that taxonomy and label them appropriately, **utilize the wp_insert_term ...


1

I added the function register_taxonomy_for_object_type( $taxonomy, $object_type ) in functions.php. First: I need to choose which kind of taxonomy I want, in this case, "category". Second: I choose the object type, in this case, "cupom" that is my Custom Post Type. add_action('init','add_categories_to_cupom'); function add_categories_to_cupom(){ ...


1

After 'public' => true, you add 'taxonomies' => array('category','post_tag'), this one create category and tag for your custom post type if you want just category the delete ,'post_tag'.


5

The documentation for register_post_type mentions a taxonomies parameter, giving it a value of array( 'category' ) will do what you want. There is also the register_taxonomy_for_object_type function


1

I haven't run this code so there may be a syntax error, but the gist is to return userfeed-taxonomy with the terms specified that have featured category OR cities-taxonomy with the terms specified and featured category OR anything else that's not those taxonomies. It's kind of clunky, maybe there is a better way: $query->set( 'tax_query', array( ...


1

Most likely the problem comes from: $terms = get_the_terms( $post->ID, $args['taxonomy'] ); i.e. you have to make sure it's not false or WP_Error object. You should also check the output of: var_dump( $args ); Try for example: if( ! is_array( $terms ) ) return $output; or if( ! $terms || is_wp_error( $terms ) ) return $output; ...


1

I am not sure what exactly you want. But I assume you want the desktop view in your mobile browser instead of responsive layout. You can use viewport to achieve this. Please check this tutorial: http://webdesign.tutsplus.com/articles/quick-tip-dont-forget-the-viewport-meta-tag--webdesign-5972


1

If you have a lot of categories it will be a pain to search everytime every category and check against the field value. I wrote something and I would love to know if it's correct or not 1st I wrote a function that get the option name from the value since wordpress core provide only a function that get the option value from name function ...


1

There is a plugin for that: WP No Category Base. This plugin will remove that part of the URL. https://wordpress.org/plugins/wp-no-category-base/


0

Hi tommyf first of all I have asked the same question here and I got the answer myself :) WordPress Tags and Hierarchy (Parent - Child relation) Here is how you should do it: $taxonomies = array( 'brands' ); $args = array( 'orderby' => 'name', 'order' => 'ASC', 'fields' ...


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

You can use pre_get_posts Exclude categories on your main page function exclude_category( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'cat', '-1,-1347' ); } } add_action( 'pre_get_posts', 'exclude_category' );


1

i'm not exactly sure the full context of what you are doing here. there are a number of possible solutions. first is to make sure you are accessing $post as you expect. in other words, make sure it is not being affected by other activity as WordPress builds the page. i don't know if $post contains the object you expect at this point in the flow -- because ...


1

Almost exactly the same to brasofilo, my code below also accounts for different taxonomies and removes the checkbox for parent categories at the top level, only if they have children. This allows for other top level categories that are childless to still be selectable. I put this simple code my theme's functions.php file: class Category_Checklist { ...


1

You need to find the according template file in the template hierarchy for the category archive, which would be, in this order, either one of those: category-{slug}.php category-{id}.php category.php archive.php index.php There you can get rid of the »Category:« part. To define the width of your content change the CSS accordingly.


0

please try this for latest pages. <?php $args = array( 'post_type' => 'page', 'posts_per_page' => 10, 'category' => '', 'orderby' => 'date', 'order' => 'DESC', ); $data = get_posts($args); print_r($data); ?>


2

Try the code below. This is the Reference: WP_Query <?php $args = array( 'post_type' => 'page', 'posts_per_page' => 10, 'category_name' => 'mycat', 'fields' => 'ids' ); $data = get_posts($args); print_r($data);


0

solved this with if ($cat_array) { foreach($cat_array as $cat) { $category = get_term_by('ID',$cat, 'category'); if($category->name != 'Excluded category'){ echo '<div class="catspace"><a href="' . esc_attr(get_term_link($category, 'category')) . '" title="' . sprintf( __( "latest posts %s" ), $category->name ) . ...


0

get_the_category() isn't the correct function - you should be using get_categories() per the dev documentation.


0

You should be able to get that number from the same $wp_query object: global $wp_query; $num_pages = $wp_query->found_posts; $num_pages will contain the total count that matches your category (or whatever other criteria you're using). If you're just looking to get a string you can display, this modified version of the function will work. function ...


1

This is mostly a PHP question and it is related to WooCommerce. Either of which conditions makes it dangerously close to off-topic. However, I am going to give the benefit of the doubt and assume that the problem is due to a misunderstanding of the WordPress function wp_get_post_terms(). ;) wp_get_post_terms() returns all of the terms as an array of term ...


0

You are missing "foreach" loop. Try this way $latest_cpt = get_posts("post_type=event"); foreach ( $latest_cpt as $cpt_post ) { $theidone =$cpt_post->ID; $this_post_id = $theidone; //get_the_ID(); $key_2_value = get_post_meta( $this_post_id, 'custom_select', true ); if( ! empty( $key_2_value )) { $thisisworking = $key_2_value ...


0

I think it is possible with custom fields. Add a custom fields, for example, named link. Put the link into the value field. Then you will be able to access it something like that: <a href="<?php echo get_post_meta( get_the_ID(), 'link', true ); ?>"> <?php the_post_thumbnail(); ?> </a>


1

I don't know what is_category_or_sub() and that function is the critical piece of code. Without it, the question of why your code doesn't work isn't answerable but there is code in the Codex that seems to do what you need: /** * Tests if any of a post's assigned categories are descendants of target categories * * @param int|array $cats The target ...


1

There is only one default term in Wordpress, that is the term uncategorized from the taxonomy category. This term is created when Wordpress is first installed. This term's ID will always be 1 if it is not altered in any other way by some custom code from a custom theme or plugin. Term ids, like post ids, are very reliable and does not change within a ...


1

Just skip the excluded category in your foreach: foreach ( $cat_array as $cat ) { if ( $cat != EXCLUDED_CAT_ID ) { // Output } }


0

I don't see where your posts are pulling from, just the category list, but you are most likely missing the post_count variable where you have your query args to retrieve the posts. post_count=-1 will return all, but it defaults to 10 (or whatever is set in your settings) if you do not specifically say otherwise.


0

This is what I'm looking for and it works well for the direct category of the post, but I can't figure how to add a current-parent-category to the parent level. Any idea?


0

There are multiple ways to go about this, but one way I would consider if I were you would be to do it like this. On the index.php or whatever page the posts appear on do the following three times each with different categories: $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $arguments = array( 'category_name' => 'category' ...


0

You can use a tax query with include_children set to false: $query = new WP_Query( array( 'tax_query' => array( array( 'taxonomy' => 'category', 'field' => 'slug', 'terms' => 'your-category-slug', 'include_children' => false, ), ), ) );


0

Just of the top of my head, something along this way might work: function wpse178647_rewrite() { add_rewrite_rule( '^([^/]+)/([^/]+)/?$', '' 'index.php?category_name=$matches[1]&pagename=$matches[2]', 'top' ); } add_action( 'init', 'wpse178647_rewrite' ); Completely and utterly untested.


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

I think you should probably use wp_list_categories(), which even has parameters for a count, like e.g. show_count and pad_counts. Additionally it supports custom walkers via the walker parameter, but the walker would be based on Walker_Category - source -, which gives you every additional styling option you want.


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

Redirect- If you did a proper redirect, there is no content on the pages you're redirecting from. So there's no issue with the content being duplicate. Tags/Categories- If the categories and tags serve a function and add value, then they're not really duplicate content. So choose categories and tags wisely. I wouldn't delete old ones because there might be ...


0

noone likes to change urls - it's an extra headache. However, google tries to be liberal, so it tries best, to accomodify your changes and not to loose your SEO, and if you redirect 301, then everything should be ok, however i think so. Of course, you should make redirection, because duplicate content is very very bad.



Top 50 recent answers are included