diff --git a/.gitignore b/.gitignore index d56272d..e52f08f 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ bin-release/ [Bb]in/ wp-admin/ wp-includes/ +html-temp/ wp-content/languages/ wp-content/mu-plugins/ wp-content/plugins/ diff --git a/wp-content/themes/nenghui-energy-theme-4/SHORTCODE_DOCUMENTATION.md b/wp-content/themes/nenghui-energy-theme-4/SHORTCODE_DOCUMENTATION.md new file mode 100644 index 0000000..f01b846 --- /dev/null +++ b/wp-content/themes/nenghui-energy-theme-4/SHORTCODE_DOCUMENTATION.md @@ -0,0 +1,611 @@ +# Nenghui Energy Theme - 短代码使用文档 + +本文档提供了 Nenghui Energy 主题中所有可用短代码的详细说明和使用示例。 + +## 目录 + +1. [产品相关短代码](#产品相关短代码) +2. [新闻相关短代码](#新闻相关短代码) +3. [关于页面短代码](#关于页面短代码) +4. [联系页面短代码](#联系页面短代码) +5. [通用组件短代码](#通用组件短代码) +6. [EPC相关短代码](#epc相关短代码) + +--- + +## 产品相关短代码 + +### `nenghui_products_list` - 产品列表 + +显示产品列表,支持分类筛选和分页。 + +**基本用法:** +```php +[nenghui_products_list] +``` + +**完整参数:** +```php +[nenghui_products_list + per_page="6" + category="residential" + order="date" + orderby="DESC" + category_order=""] +``` + +**参数说明:** +- `per_page` - 每页显示的产品数量(默认:6) +- `category` - 筛选特定分类(留空显示所有) +- `order` - 排序方式(默认:date) +- `orderby` - 排序字段(默认:DESC) +- `category_order` - 自定义分类排序 + +**产品自定义字段:** +- `cate_type` - 产品分类(必需) +- `cate_type_value` - 分类显示名称 +- `efficiency` - 效率值(如:≥93% Efficiency) +- `is_new` - 是否为新产品(true/false) +- `attr_key` - 属性名称(逗号分隔) +- `attr_value` - 属性值(逗号分隔) +- `_product_banner_url` - 产品横幅图片URL +- `_usage_scenario_data` - 使用场景数据(包含bottom_text) + +**示例:** +```php +// 显示所有产品,每页9个 +[nenghui_products_list per_page="9"] + +// 只显示residential分类的产品 +[nenghui_products_list category="residential"] + +// 自定义排序 +[nenghui_products_list order="title" orderby="ASC"] +``` + +--- + +### `nenghui_products_banner` - 产品横幅 + +显示产品页面横幅。 + +**基本用法:** +```php +[nenghui_products_banner] +``` + +或简化版本: +```php +[products_banner] +``` + +--- + +### `nenghui_warehousing_distribution` - 仓储配送 + +显示仓储配送信息。 + +**基本用法:** +```php +[nenghui_warehousing_distribution] +``` + +或简化版本: +```php +[warehousing_distribution] +``` + +--- + +## 新闻相关短代码 + +### `nenghui_news` - 新闻列表 + +显示新闻文章列表。 + +**基本用法:** +```php +[nenghui_news] +``` + +**完整参数:** +```php +[nenghui_news + title="最新资讯" + category_id="1" + posts_count="6" + order_by="date" + order="DESC"] +``` + +**参数说明:** +- `title` - 模块标题 +- `category_id` - 分类ID +- `posts_count` - 显示文章数量 +- `order_by` - 排序字段 +- `order` - 排序方向 + +--- + +### `nenghui_news_grid` - 新闻网格 + +以网格布局显示新闻。 + +**基本用法:** +```php +[nenghui_news_grid] +``` + +--- + +## 关于页面短代码 + +### `nenghui_about_nav` - 关于导航 + +显示关于页面的导航菜单。 + +**基本用法:** +```php +[nenghui_about_nav] +``` + +**自定义参数:** +```php +[nenghui_about_nav menu_id="123"] +``` + +**参数说明:** +- `menu_id` - 指定菜单ID(留空使用自定义器设置的默认菜单) + +--- + +### `nenghui_about_company` - 关于公司 + +显示公司介绍信息。 + +**基本用法:** +```php +[nenghui_about_company] +``` + +**自定义参数:** +```php +[nenghui_about_company show_animation="true"] +``` + +**参数说明:** +- `show_animation` - 是否显示动画效果 + +--- + +### `nenghui_development_history` - 发展历程 + +显示公司发展历程时间线。 + +**基本用法:** +```php +[nenghui_development_history] +``` + +**自定义参数:** +```php +[nenghui_development_history show_animation="true"] +``` + +--- + +### `nenghui_certification_gallery` - 认证画廊 + +显示公司认证证书画廊。 + +**基本用法:** +```php +[nenghui_certification_gallery] +``` + +**自定义参数:** +```php +[nenghui_certification_gallery + columns="5" + lightbox="true" + animation="true"] +``` + +**参数说明:** +- `columns` - 每行显示列数(1-6) +- `lightbox` - 是否启用灯箱效果 +- `animation` - 是否启用动画效果 + +--- + +### `nenghui_technical_service` - 技术服务 + +显示技术服务信息。 + +**基本用法:** +```php +[nenghui_technical_service] +``` + +**自定义参数:** +```php +[nenghui_technical_service + title="可靠的技术服务" + subtitle="提升客户体验"] +``` + +--- + +### `black_about_company_banner` - 关于公司横幅 + +显示关于页面的横幅。 + +**基本用法:** +```php +[black_about_company_banner] +``` + +--- + +### `nenghui_black_about_info` - 关于信息 + +显示公司详细信息。 + +**基本用法:** +```php +[nenghui_black_about_info] +``` + +或简化版本: +```php +[black_about_info] +``` + +--- + +### `business_process` - 业务流程 + +显示业务流程图。 + +**基本用法:** +```php +[business_process] +``` + +--- + +## 联系页面短代码 + +### `nenghui_contact_form` - 联系表单 + +显示联系表单。 + +**基本用法:** +```php +[nenghui_contact_form] +``` + +**自定义参数:** +```php +[nenghui_contact_form form_id="1" show_animation="true"] +``` + +**参数说明:** +- `form_id` - 表单ID +- `show_animation` - 是否显示动画效果 + +--- + +### `nenghui_contact_map` - 联系地图 + +显示联系地图。 + +**基本用法:** +```php +[nenghui_contact_map] +``` + +--- + +### `nenghui_overseas_services` - 海外服务 + +显示海外服务信息。 + +**基本用法:** +```php +[nenghui_overseas_services] +``` + +--- + +## 通用组件短代码 + +### `nenghui_banner` - 轮播横幅 + +显示轮播横幅。 + +**基本用法:** +```php +[nenghui_banner] +``` + +**自定义参数:** +```php +[nenghui_banner autoplay="true"] +``` + +**参数说明:** +- `autoplay` - 是否自动播放 + +--- + +### `nenghui_futures` - 未来展望 + +显示未来展望内容。 + +**基本用法:** +```php +[nenghui_futures] +``` + +**自定义参数:** +```php +[nenghui_futures title="未来展望" show_animation="true"] +``` + +--- + +### `nenghui_tabs` - 选项卡 + +显示选项卡内容。 + +**基本用法:** +```php +[nenghui_tabs] +``` + +**自定义参数:** +```php +[nenghui_tabs tabs_count="3" show_animation="true"] +``` + +--- + +### `nenghui_flowchart_tabs` - 流程图选项卡 + +显示流程图选项卡。 + +**基本用法:** +```php +[nenghui_flowchart_tabs] +``` + +--- + +### `nenghui_banner_title` - 标题横幅 + +显示带标题的横幅。 + +**基本用法:** +```php +[nenghui_banner_title title="关于我们" description="我们致力于提供最优质的服务"] +``` + +**完整参数:** +```php +[nenghui_banner_title + title="关于我们" + description="我们致力于提供最优质的服务" + bg_image="https://example.com/image.jpg" + height="70vh" + overlay_opacity="0.6" + show_animation="true"] +``` + +**参数说明:** +- `title` - 标题 +- `description` - 描述 +- `bg_image` - 背景图片URL +- `height` - 高度(支持px、vh、%) +- `overlay_opacity` - 遮罩透明度(0-1) +- `show_animation` - 是否显示动画 + +--- + +### `black_maps` - 黑色地图 + +显示交互式地图。 + +**基本用法:** +```php +[black_maps] +``` + +**自定义参数:** +```php +[black_maps height="100vh" show_loading="true"] +``` + +**参数说明:** +- `height` - 地图高度 +- `show_loading` - 是否显示加载动画 + +--- + +### `nenghui_video` - 视频 + +显示视频播放器。 + +**基本用法:** +```php +[nenghui_video video_url="https://example.com/video.mp4"] +``` + +**完整参数:** +```php +[nenghui_video + video_url="https://example.com/video.mp4" + cover_image="https://example.com/cover.jpg" + title="我们的企业视频" + description="了解我们的产品和服务" + play_button_text="立即播放" + show_overlay="true" + overlay_opacity="0.5" + height="80vh" + autoplay="false" + muted="true" + controls="true"] +``` + +**参数说明:** +- `video_url` - 视频URL(必需) +- `cover_image` - 封面图片URL +- `title` - 视频标题 +- `description` - 视频描述 +- `play_button_text` - 播放按钮文字 +- `show_overlay` - 是否显示遮罩 +- `overlay_opacity` - 遮罩透明度 +- `height` - 视频高度 +- `autoplay` - 是否自动播放 +- `muted` - 是否静音 +- `controls` - 是否显示控制栏 + +--- + +### `nenghui_download_center` - 下载中心 + +显示下载中心。 + +**基本用法:** +```php +[nenghui_download_center] +``` + +--- + +### `nenghui_faq` - 常见问题 + +显示常见问题列表。 + +**基本用法:** +```php +[nenghui_faq] +``` + +--- + +### `nenghui_cases` - 案例展示 + +显示案例展示。 + +**基本用法:** +```php +[nenghui_cases] +``` + +--- + +## EPC相关短代码 + +### `nenghui_epc` - EPC解决方案 + +显示EPC解决方案。 + +**基本用法:** +```php +[nenghui_epc] +``` + +**自定义参数:** +```php +[nenghui_epc + title="EPC Solutions" + subtitle="Beyond Hardware: Total EPC Solutions from NengHui Design Institute" + bg_image="https://example.com/epc-bg.jpg"] +``` + +--- + +### `nenghui_epc_banner` - EPC横幅 + +显示EPC横幅。 + +**基本用法:** +```php +[nenghui_epc_banner] +``` + +--- + +## 使用技巧 + +### 1. 在页面编辑器中使用 + +在WordPress页面编辑器中,直接输入短代码即可: + +``` +[nenghui_products_list per_page="9"] +``` + +### 2. 在模板文件中使用 + +在主题模板文件中使用 `do_shortcode()` 函数: + +```php + +``` + +### 3. 组合使用多个短代码 + +可以在同一个页面中使用多个短代码: + +``` +[nenghui_banner_title title="我们的产品"] +[nenghui_products_list per_page="9"] +[nenghui_contact_form] +``` + +### 4. 响应式设计 + +所有短代码都支持响应式设计,会自动适应不同屏幕尺寸。 + +### 5. 深色模式 + +所有短代码都支持深色模式,会自动根据系统设置切换主题。 + +## 常见问题 + +### Q: 短代码不显示怎么办? + +A: 请确保: +1. 短代码名称拼写正确 +2. 主题已正确激活 +3. 没有PHP错误(检查调试日志) + +### Q: 如何自定义短代码样式? + +A: 可以通过以下方式自定义: +1. 在自定义器中修改相关设置 +2. 使用CSS覆盖默认样式 +3. 修改对应的模板文件 + +### Q: 短代码参数不生效怎么办? + +A: 请确保: +1. 参数名称拼写正确 +2. 参数值格式正确 +3. 没有特殊字符冲突 + +### Q: 如何添加新的短代码? + +A: 可以在 `inc/shortcode.php` 文件中添加新的短代码函数,参考现有短代码的实现方式。 + +## 技术支持 + +如需技术支持,请联系开发团队或查看主题文档。 + +--- + +**文档版本:** 1.0 +**最后更新:** 2026-02-09 +**主题版本:** nenghui-energy-theme-4 diff --git a/wp-content/themes/nenghui-energy-theme-4/functions.php b/wp-content/themes/nenghui-energy-theme-4/functions.php index af6aa5b..5a48930 100644 --- a/wp-content/themes/nenghui-energy-theme-4/functions.php +++ b/wp-content/themes/nenghui-energy-theme-4/functions.php @@ -334,4 +334,139 @@ class Nenghui_Walker_Nav_Menu extends Walker_Nav_Menu { } } +function get_post_meta_by_key($key, $cate_type) { + global $wpdb; + $table = $wpdb->postmeta; + $result = $wpdb->get_var($wpdb->prepare( + "SELECT meta_value FROM $table WHERE meta_key = %s AND post_id IN ( + SELECT post_id FROM $table WHERE meta_key = 'cate_type' AND meta_value LIKE %s + ) LIMIT 1", + $key, + '%' . $wpdb->esc_like($cate_type) . '%' + )); + return $result; +} + +add_action('wp_ajax_load_more_products', 'load_more_products_callback'); +add_action('wp_ajax_nopriv_load_more_products', 'load_more_products_callback'); + +function load_more_products_callback() { + check_ajax_referer('load_more_products_nonce', 'nonce'); + + $offset = intval($_POST['offset']); + $per_page = intval($_POST['per_page']); + $category = isset($_POST['category']) ? sanitize_text_field($_POST['category']) : ''; + + $meta_query = array(); + + if (!empty($category) && $category !== 'all') { + $meta_query[] = array( + 'key' => 'cate_type', + 'value' => $category, + 'compare' => 'LIKE' + ); + } + + $query_args = array( + 'post_type' => 'products', + 'posts_per_page' => $per_page, + 'offset' => $offset, + 'meta_query' => $meta_query, + 'post_status' => 'publish' + ); + + $products_query = new WP_Query($query_args); + $products = array(); + + if ($products_query->have_posts()) { + while ($products_query->have_posts()) { + $products_query->the_post(); + $post_id = get_the_ID(); + $cate_type = get_post_meta($post_id, 'cate_type', true); + + $cover_image = get_the_post_thumbnail_url($post_id, 'product-cover-medium'); + if (empty($cover_image)) { + $cover_image = get_post_meta($post_id, '_product_banner_url', true); + } + if (empty($cover_image)) { + $cover_image = get_template_directory_uri() . '/assets/images/products-1.webp'; + } + + $usage_scenario_data = get_post_meta($post_id, '_usage_scenario_data', true); + $description = ''; + if (!empty($usage_scenario_data) && isset($usage_scenario_data['bottom_text'])) { + $description = $usage_scenario_data['bottom_text']; + } + $attr_keys = get_post_meta($post_id, 'attr_key', true); + $attr_values = get_post_meta($post_id, 'attr_value', true); + $attr_keys_array = !empty($attr_keys) ? explode(',', $attr_keys) : array(); + $attr_values_array = !empty($attr_values) ? explode(',', $attr_values) : array(); + $attrs = array(); + for ($i = 0; $i < min(4, count($attr_keys_array)); $i++) { + if (isset($attr_keys_array[$i]) && isset($attr_values_array[$i])) { + $attrs[] = array( + 'key' => trim($attr_keys_array[$i]), + 'value' => trim($attr_values_array[$i]) + ); + } + } + $efficiency = get_post_meta($post_id, 'efficiency', true); + $is_new = get_post_meta($post_id, 'is_new', true); + $is_new_value = filter_var($is_new, FILTER_VALIDATE_BOOLEAN); + + ob_start(); + ?> +
| '; @@ -404,23 +409,23 @@ function download_file_info_callback($post) { echo ' | '; echo ' |
|---|
请填写下载文件的相关信息。如果不填写下载链接,将使用特色图像作为下载文件。
'; - + // 添加JavaScript代码用于媒体库选择 echo ' + ID, '_product_description', true); ?>产品特性板块设置:
- +勾选此选项将在前端显示产品特性卡片,取消勾选将隐藏整个板块。
注意:修改后需要点击"更新"按钮保存设置。
- + - + \ No newline at end of file