categories

Get the id of a WooCommerce category, by name

天涯浪子 提交于 2020-02-03 08:52:27
问题 I have a wp template that I would like to assign to some pages. The template would ie. display all WooCommerce products that have the same master category name as the pages name itself. By far I have tried using this code, but with no good output: $idObj = get_category_by_slug($pagename); $id = $idObj->term_id; echo ": ". $id; Unfortunately, the echo does not display anything. Echoing $pagename works, and returns me the slug of the page. Any good way I could make this work? 回答1: With a custom

Android Categorized listview with heading

老子叫甜甜 提交于 2020-02-02 03:43:25
问题 I have to display data from the database in a listview. I have fetch all the data in group by categoty and displayed in a Listview. I have used the following code. private ListView infos; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ......... ......... infos = new ListView(this); model = infoDataHelper.getCursor(addType); adapter = new InfoAdapter(model); infos.setAdapter(adapter); ......... ......... } class InfoAdapter extends CursorAdapter

Get current category ID of the active page

烂漫一生 提交于 2020-01-27 08:54:27
问题 Looking to pull the category ID of a specific page in WordPress that is listing all posts using that specific category. Tried the below but not working. I am able to get the category name using single_term_title . $category = single_term_title("", false); $catid = get_cat_ID( $category ); $category is displaying "Entertainment" for example. But I also need the ID of "Entertainment". How would I go about this? 回答1: You can try using get_the_category(): $categories = get_the_category();

Show category names of current page in TYPO3 8

萝らか妹 提交于 2020-01-25 09:02:41
问题 I am trying to display the category name(s) of the current page on a TYPO3 8 installation. In TYPO3 7 it used to work like this (see below), however now I only receive a random error code and no Text output. Any Ideas? lib.catclass = CONTENT lib.catclass { wrap = <div class="categories">|</div> table = sys_category select { pidInList = 35 // UiD of your category_page join = sys_category_record_mm ON(sys_category_record_mm.uid_local=sys_category.uid) where = sys_category_record_mm.tablenames=

Magento export categories -> import with magmi

筅森魡賤 提交于 2020-01-25 02:48:08
问题 we need to change the categories of some products and it is easier for us to do this with a csv file. Is there a way to export the categories in magmi format? sku,categories "abc","cat1/cat2;;cat5/cat6/cat1" "bgb","cat1/cat2" or is there maybe a small tool to manage the products in categories? Edit: this is the current code which is displaying the category names. But I am trying to display the category path like this: FirstCat/Tools/Screwdriver But it is displaying like this: FirstCat

Wordpress, get ID's of multiple categories from the URL

隐身守侯 提交于 2020-01-24 00:57:27
问题 I'm using WordPress 2.8.4. My question is, if I'm viewing a sub category ( cat-slug-2 in this example) is there a built in function to get it's category ID and its parents category ID ? Here's an example URL, where cat-slug-2 is a sub category of cat-slug-1 http://www.foo.com/category/cat-slug-1/cat-slug-2/ 回答1: Maybe something like this? <?php $current_category = single_cat_title("", false); $category_ID = $wpdb->get_var( "SELECT term_id FROM $wpdb->terms WHERE slug = '" . $current_category

Magento Sort Categories Alphabetically

吃可爱长大的小学妹 提交于 2020-01-17 03:00:36
问题 recently I was asked to display top-level categories and its sub-categories on left navigation in alphabetical order. The code I'am using is <ul id="demo1" class="nav"> <?php $helper = Mage::helper('catalog/category') ?> <?php $categories = $helper->getStoreCategories(); ?> <?php foreach ($categories as $_category): ?> <?php echo $this->drawItem($_category) ?> <?php endforeach ?> </ul> Unfortunately it displays the categories but not alphabetically. Also is it not displaying because I am

How to add category(posts) in wordpress single post

こ雲淡風輕ζ 提交于 2020-01-16 21:35:38
问题 Hey any one know how to add a specific category posts in wordpress single post.m giving a link of website that is using it http://www.animetv.org/anime/one-piece-dub/ it is a post that contains posts of a particular category.It is demanded as same i.e. with post thumbnails.Thanks. 回答1: Just put this code at your single.php file you will get your desired result: <?php $category = get_the_category(); ?> <ul> <?php $args = array('category' => $category[0]->term_id ); $myposts = get_posts( $args

How do I add categories or tags to a Svelte/Sapper markdown site?

隐身守侯 提交于 2020-01-16 09:47:03
问题 Forking this question off from Sapper/Svelte: How do I add markdown files? to help future searchers: I see that all the posts will have a link right after the Top-Level Domain Ex www.example.com/post1 , www.example.com/post2 . But what if someone using the template wants to categorize the posts. Ex www.example.com/svelte-posts/post1 , www.example.com/vuejs-posts/post1 回答1: If you want traditional WordPress-style categories I would add that to the markdown front matter of the posts (Jekyll

PHP Reverse Category Tree array to Breadcrumb List

隐身守侯 提交于 2020-01-16 04:19:06
问题 I have a category tree array fetched from MySQL Table. I want to revert this Category array tree back into Breadcrumb list using PHP. PHP Category Tree Building Function function buildTree(array &$elements, $parentId = 0) { $branch = array(); foreach ($elements as $element) { if ($element['parent_category_id'] == $parentId) { $children = buildTree($elements, $element['category_id']); if ($children) { $element['children'] = $children; } $branch[$element['category_id']] = $element; unset(