categories

how to use the category name as url suffix in Django

半腔热情 提交于 2019-12-11 15:40:19
问题 Now my url is like:https://mywebsite.com/newscategory_lists-5 I want change it to:https://mywebsite.com/categoryname Here is my model: class Category(models.Model): name = models.CharField(max_length=40) # 分类名 class Meta: verbose_name = "分类" verbose_name_plural = verbose_name def __str__(self): return self.name Here is the urls.py: path('category_lists-<int:category_pk>', views.categoryNewsList, name="category_news_list"), Here is my view.py: def categoryNewsList(request, category_pk):

Linking error of a header file in xcode , when made a static libary

走远了吗. 提交于 2019-12-11 15:34:35
问题 What I was doing is as follows.. 1) First I used the OAConsumer library and Base64 library in my project and I made a cocoa touch static library of it along with my own classes.. 2)When I use this library in my project , it is not able to link the NSData + BAse64.m file I get the following error and it crashes .. -[NSConcreteData base64EncodedString] : Unrecognised selector sent to instance 0x158250 This question is similar to the following question .. Categories in Objective-C aren't working

Multiple Select with wp_dropdown_categories wordpress

别来无恙 提交于 2019-12-11 11:40:25
问题 I want to add a widget that shows a category list with the latest post shown. However i have found the plugin http://wordpress.org/extend/plugins/category-posts/ But this plugin shows only one category at a time. When i open the widget file cat-posts.php I saw the code wp_dropdown_list . So can you tell me how can make this to select multiple categories to show all categories with latest post. Is it possible or there is another way to do the same task. Please suggest. Any help will be greatly

Best solution for drag/drop category/subcategory? Tried jQuery UI sortable, now stuck

本小妞迷上赌 提交于 2019-12-11 08:33:38
问题 I have a very crude category list right now, but I'm wanting it to make it look and behave more like WordPress admin does it, where you can drag a category into another category. Code looks like this: <ul class="categories"> <li>Real Estate</li> <li>Home Improvements</li> <ul class="categories"> <li>Interior</li> <li>Exterior</li> <ul class="categories"> <li>Exterior Subcat</li> </ul> </ul> </ul> I tried jQuery UI's sortable, and told it to sort <li> 's only, but the list items wouldn't drag

Wordpress: Hide specific categories from User Role on the Add New page

你离开我真会死。 提交于 2019-12-11 07:35:51
问题 Just as title says really; How can i hide specific categories from specified User Roles in Wordpress on the Add New Post page? So that users of a specific role cannot see the hidden categories (therefore, not post in them either). I used to do this via a plugin but they havnt been updated in years and i dont seem able to find a replacement. So any help would be appreciated. Cheers 回答1: Answer converted to comment. Apply this code to your own and should work. add_filter('list_terms_exclusions'

Wordpress: how to get first level of children from a category?

一个人想着一个人 提交于 2019-12-11 07:14:02
问题 I want to know if has a function that return only the first level of subcategories children. Cat 1 Sub-1.1 Sub-1.2 Sub-1.2.1 Cat 2 Sub-2.1 Here I want only: Sub-1.1, Sub-1.2 and Sub-2.1 Cause using get_categories with child_of parameter brings me all children until the last node: get_categories('orderby=id&show_count=0&title_li=&use_desc_for_title=1&child_of='.$this_category->cat_ID); Thanks 回答1: Please try wp_list_categories(array('depth' => 2)); 来源: https://stackoverflow.com/questions

Related Products only by categories, not by tags in WooCommerce 3

落花浮王杯 提交于 2019-12-11 06:37:50
问题 Trying to display related products in WooCommerce by categories only. At present WooCommerce uses tags and categories. We've tried implementing the following, but I'm guessing over time this will have stopped working perhaps owing to updates on WooCommerce side. It now no longer works in any theme we've tested. add_filter( 'woocommerce_product_related_posts_relate_by_tag', '__return_false' ); 回答1: NOTE: this hook is working again now. A functional alternative: Looking at the related core code

Discount based on cart items count and product categories

☆樱花仙子☆ 提交于 2019-12-11 05:59:39
问题 I am trying to add a custom cart discount based on a minimal cart item count and categories. I have take the code from this answer: Cart discount based on cart item count and only for items that are not in sale I have made some changes to it and this is my code: add_action('woocommerce_cart_calculate_fees' , 'my_custom_discount', 10, 1); function my_custom_discount( $cart_object ){ if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return; // Only when there is 4 or more items in cart if( $cart

Filtering content (jQuery)

橙三吉。 提交于 2019-12-11 05:55:17
问题 HTML: <div class="filter"> <a href="#category-1">category 1</a> <a href="#category-2">category 2</a> </div> <ul class="items"> <li class="category-1">item 1</li> <li class="category-1">item 2</li> <li class="category-2">item 3</li> <li class="category-2">item 4</li> </ul> What I want is for example clicking on 'category 1' link should hide all other category items from the list. I understand jQuery's .filter() selector can be used but I'm not sure how to implement it for my purpose here.

ACF - Display image from Custom Post Type custom Category

岁酱吖の 提交于 2019-12-11 05:42:02
问题 I have a problem and I believe the answer lies here: https://www.advancedcustomfields.com/resources/get-values-from-a-taxonomy-term/ But I cant figure out how to apply it to my code... I have used Advanced Custom Fields to add an image field inside the categories of a custom post type. My custom post type is call Short Courses, and the category name is Course Types. Here's the loop: <?php $customPostTaxonomies = get_object_taxonomies('short_courses'); if(count($customPostTaxonomies) > 0) {