categories

List wordpress posts by category which match page title

浪子不回头ぞ 提交于 2019-12-08 11:25:59
问题 I'm trying to list posts in the category which shares the name of the page. I.e. If you are on the "Services" page it should display posts in the category "Services". I realize it is easy to do with conditionals such as: <?php if ( (is_page('Groups')) ) { query_posts('category_name=groups'); while (have_posts()) { the_post();?> <h2 class="title" id="sub">Upcoming Group Programs</h2> <a href="<?php the_permalink() ?>"> <div class="post" id="post-<?php the_ID(); ?>"> <h2><?php the_title(); ?><

Category Hierarchy (PHP/MySQL) in Yii

情到浓时终转凉″ 提交于 2019-12-08 11:24:42
问题 I found this here: Category Hierarchy (PHP/MySQL) And i want to display that code, but it is not working correctly. I got the following Hierarchy: -Airsoft --Scopes That's all. But the code is displaying: -Airsoft --Scopes (So far so good) -Scopes <--- this one should not be here! Here's the code: public static function producten(){ $connection=Yii::app()->db; // assuming you have configured a "db" connection $sql = 'SELECT id, parent, naam FROM categories ORDER BY naam'; $command=$connection

Replace add to cart button with a custom button on WooCommerce

十年热恋 提交于 2019-12-08 10:38:15
问题 I would like to replace the 'Add to cart' button for a specific product category and when product type isa a 'simple product' . I would like to do that on the page where I can see all the products (shop and archive pages) and in single product pages. The code bellow just hide my add-to cart buttons from all post of my product category: function western_custom_buy_buttons(){ $product = get_product(); if ( has_term( 'categ1', 'product_cat') ){ // removing the purchase buttons remove_action(

Deleting a item from multilevel category or menu list

时间秒杀一切 提交于 2019-12-08 10:36:17
问题 I am making Categories system management like WordPress. As you can see in my database if i delete (or updating delete to 1) a category. All its child disappear fro the list. Before delete -> After delete -> But this not happening in the WordPress case. It deletes the selected category and assign its child to the parent of deleted category. I want to do the same. Step 1 -> get the parent of category which will be deleted. Step 2 -> update parent field of all child's of selected category with

Adding Sub-categories in Rails4

大兔子大兔子 提交于 2019-12-08 09:39:25
问题 I have a lot of Main Categories and want to add to each sub categories.-> Main Category -Sub Category -Sub Category -Sub Category Main Category -Sub Category -Sub Category -Sub Category A lot of people recommend me to use a gem, but as i am fairly new to Rails i rather learn how to do this on my own, to learn all they way through. Should i start with a Scaffold or simply a Model ? Could someone explain me how to start (migrations etc.) and how to set it up? Thank you. 回答1: You have to

woocommerce display parent category thumbnail only (taxonomy-product_cat.php)

大城市里の小女人 提交于 2019-12-08 07:37:43
问题 I created a function that display parent category thumbnails for all the pages that uses this template ( taxonomy-product_cat.php ) . The function is working on one of my parent and it's subcategories (category 1 with 6 subcategories), the problem is on the other category (category 2 with 6 subcategories) I created. It repeats the echo 6 times = equivalent to the number of it's subcategories. I don't know what's causing it. function woocommerce_get_parent_thumbnail() { global $post; $prod

Creating Wordpress Category at the time of Theme Activation

心不动则不痛 提交于 2019-12-08 04:27:57
问题 I am going to create a function that will check whether if a Category named Testimonials is already available or not. If it is available do noting, whereas if it is not there, then create a new Category named Testimonials . I am using following code but nothing happened at the time of theme activation. What is missing? function create_my_cat () { if (file_exists (ABSPATH.'/wp-admin/includes/taxonomy.php')) { require_once (ABSPATH.'/wp-admin/includes/taxonomy.php'); if (!get_cat_ID(

Is it possible in WordPress to test for an empty term or category?

混江龙づ霸主 提交于 2019-12-08 03:25:57
问题 I have a project that requires me to list out the available terms for each custom post type and indicate visually which of the terms/categories are empty via css/javascript. Is there a way to return a list of terms/categories and say add a class to the empty ones ? Thanks for any and all assistance. 回答1: Yes there is. First you get your terms using get_terms() (I'm assuming your cpt has associated taxonomy with it) <?php $custom_terms = get_terms('my_taxonomy'); if (is_array($custom_terms) &&

Allow only one product per product category in cart

我是研究僧i 提交于 2019-12-08 03:13:26
On this Question / Answer I have found the PHP code about how to just add one product per category in cart in Woocommerce. The code works just fine, but I want to add the latest added product to cart and if there is already a product of that category in the cart, I want to have the oldest deleted. add_filter( 'woocommerce_add_to_cart_validation', 'custom_checking_product_added_to_cart', 10, 3 ); function custom_checking_product_added_to_cart( $passed, $product_id, $quantity) { // HERE Type your alert displayed message // $message = __( 'BLA BLA YOUR MESSAGE.', 'woocommerce' ); $product_cats

how to get category name from category id?

99封情书 提交于 2019-12-07 16:55:50
问题 I am new in joomla.In my module i have to give select category option. I tried to get category name from back-end by following code but it doesn't work.Code.. $backId=$params->get('mycategory'); $db->setQuery('SELECT cat.title FROM #__categories cat RIGHT JOIN #__content cont ON cat.id = cont.catid WHERE cont.id='.$backId); $category_title = $db->loadResult(); if ($category_title) { echo $category_title; } how can i get the category name that i selected.Thanks... 回答1: Hope this may be work..