shortcode 相关问题

短代码允许Wordpress插件作者以简洁的方式为其功能提供钩子。在2.5版中引入,短代码是接受可选属性的对象的定义。如果要实现短代码并需要有关底层功能的帮助,请使用此标记。

Wordpress 短代码未在 Yoast og:title 中呈现

我有一个简单的简码,用于帖子标题: add_shortcode('年份', 'year_shortcode'); 函数year_shortcode() { $年份=日期('Y'); 返回$年; } add_filter('single_post_title...

回答 3 投票 0

PHP 自定义简码正在附加单词“Array”。我该如何摆脱这个?

我有一个自定义的短代码,显示我的帖子的最后更新日期。短代码正在输出正确的日期,但附加了单词“Array”?我该如何摆脱这个? //最后更新...

回答 1 投票 0

如何在Wordpress中获取所有国家/地区的下拉列表

是否有一种更短的方法可以让所有国家/地区填充选项,而不是在下面的下拉列表中逐一编写选项? 是否有一种更短的方法来让所有国家/地区填充选项,而不是在下面的下拉列表中逐一编写选项? <select name="input-country" id="input-country" class="form-control form-control-alternative"> <option value="">Select a country / region…</option> <option value="AF">Afghanistan</option> <option value="AX">Åland Islands</option> <option value="AL">Albania</option> </select> 或者如何在 Wordpress 中获取所有国家/地区的下拉列表? 以下自定义短代码将显示国家/地区下拉列表: // Utility function: Return an array of countries (code / name pairs) function get_all_countries() { return array( 'AF' => __('Afghanistan'), 'AX' => __('Åland Islands'), 'AL' => __('Albania'), 'DZ' => __('Algeria'), 'AS' => __('American Samoa'), 'AD' => __('Andorra'), 'AO' => __('Angola'), 'AI' => __('Anguilla'), 'AQ' => __('Antarctica'), 'AG' => __('Antigua and Barbuda'), 'AR' => __('Argentina'), 'AM' => __('Armenia'), 'AW' => __('Aruba'), 'AU' => __('Australia'), 'AT' => __('Austria'), 'AZ' => __('Azerbaijan'), 'BS' => __('Bahamas'), 'BH' => __('Bahrain'), 'BD' => __('Bangladesh'), 'BB' => __('Barbados'), 'BY' => __('Belarus'), 'PW' => __('Belau'), 'BE' => __('Belgium'), 'BZ' => __('Belize'), 'BJ' => __('Benin'), 'BM' => __('Bermuda'), 'BT' => __('Bhutan'), 'BO' => __('Bolivia'), 'BQ' => __('Bonaire, Saint Eustatius and Saba'), 'BA' => __('Bosnia and Herzegovina'), 'BW' => __('Botswana'), 'BV' => __('Bouvet Island'), 'BR' => __('Brazil'), 'IO' => __('British Indian Ocean Territory'), 'BN' => __('Brunei'), 'BG' => __('Bulgaria'), 'BF' => __('Burkina Faso'), 'BI' => __('Burundi'), 'KH' => __('Cambodia'), 'CM' => __('Cameroon'), 'CA' => __('Canada'), 'CV' => __('Cape Verde'), 'KY' => __('Cayman Islands'), 'CF' => __('Central African Republic'), 'TD' => __('Chad'), 'CL' => __('Chile'), 'CN' => __('China'), 'CX' => __('Christmas Island'), 'CC' => __('Cocos (Keeling) Islands'), 'CO' => __('Colombia'), 'KM' => __('Comoros'), 'CG' => __('Congo (Brazzaville)'), 'CD' => __('Congo (Kinshasa)'), 'CK' => __('Cook Islands'), 'CR' => __('Costa Rica'), 'HR' => __('Croatia'), 'CU' => __('Cuba'), 'CW' => __('Curaçao'), 'CY' => __('Cyprus'), 'CZ' => __('Czech Republic'), 'DK' => __('Denmark'), 'DJ' => __('Djibouti'), 'DM' => __('Dominica'), 'DO' => __('Dominican Republic'), 'EC' => __('Ecuador'), 'EG' => __('Egypt'), 'SV' => __('El Salvador'), 'GQ' => __('Equatorial Guinea'), 'ER' => __('Eritrea'), 'EE' => __('Estonia'), 'SZ' => __('Eswatini'), 'ET' => __('Ethiopia'), 'FK' => __('Falkland Islands'), 'FO' => __('Faroe Islands'), 'FJ' => __('Fiji'), 'FI' => __('Finland'), 'FR' => __('France'), 'GF' => __('French Guiana'), 'PF' => __('French Polynesia'), 'TF' => __('French Southern Territories'), 'GA' => __('Gabon'), 'GM' => __('Gambia'), 'GE' => __('Georgia'), 'DE' => __('Germany'), 'GH' => __('Ghana'), 'GI' => __('Gibraltar'), 'GR' => __('Greece'), 'GL' => __('Greenland'), 'GD' => __('Grenada'), 'GP' => __('Guadeloupe'), 'GU' => __('Guam'), 'GT' => __('Guatemala'), 'GG' => __('Guernsey'), 'GN' => __('Guinea'), 'GW' => __('Guinea-Bissau'), 'GY' => __('Guyana'), 'HT' => __('Haiti'), 'HM' => __('Heard Island and McDonald Islands'), 'HN' => __('Honduras'), 'HK' => __('Hong Kong'), 'HU' => __('Hungary'), 'IS' => __('Iceland'), 'IN' => __('India'), 'ID' => __('Indonesia'), 'IR' => __('Iran'), 'IQ' => __('Iraq'), 'IE' => __('Ireland'), 'IM' => __('Isle of Man'), 'IL' => __('Israel'), 'IT' => __('Italy'), 'CI' => __('Ivory Coast'), 'JM' => __('Jamaica'), 'JP' => __('Japan'), 'JE' => __('Jersey'), 'JO' => __('Jordan'), 'KZ' => __('Kazakhstan'), 'KE' => __('Kenya'), 'KI' => __('Kiribati'), 'KW' => __('Kuwait'), 'KG' => __('Kyrgyzstan'), 'LA' => __('Laos'), 'LV' => __('Latvia'), 'LB' => __('Lebanon'), 'LS' => __('Lesotho'), 'LR' => __('Liberia'), 'LY' => __('Libya'), 'LI' => __('Liechtenstein'), 'LT' => __('Lithuania'), 'LU' => __('Luxembourg'), 'MO' => __('Macao'), 'MG' => __('Madagascar'), 'MW' => __('Malawi'), 'MY' => __('Malaysia'), 'MV' => __('Maldives'), 'ML' => __('Mali'), 'MT' => __('Malta'), 'MH' => __('Marshall Islands'), 'MQ' => __('Martinique'), 'MR' => __('Mauritania'), 'MU' => __('Mauritius'), 'YT' => __('Mayotte'), 'MX' => __('Mexico'), 'FM' => __('Micronesia'), 'MD' => __('Moldova'), 'MC' => __('Monaco'), 'MN' => __('Mongolia'), 'ME' => __('Montenegro'), 'MS' => __('Montserrat'), 'MA' => __('Morocco'), 'MZ' => __('Mozambique'), 'MM' => __('Myanmar'), 'NA' => __('Namibia'), 'NR' => __('Nauru'), 'NP' => __('Nepal'), 'NL' => __('Netherlands'), 'NC' => __('New Caledonia'), 'NZ' => __('New Zealand'), 'NI' => __('Nicaragua'), 'NE' => __('Niger'), 'NG' => __('Nigeria'), 'NU' => __('Niue'), 'NF' => __('Norfolk Island'), 'KP' => __('North Korea'), 'MK' => __('North Macedonia'), 'MP' => __('Northern Mariana Islands'), 'NO' => __('Norway'), 'OM' => __('Oman'), 'PK' => __('Pakistan'), 'PS' => __('Palestinian Territory'), 'PA' => __('Panama'), 'PG' => __('Papua New Guinea'), 'PY' => __('Paraguay'), 'PE' => __('Peru'), 'PH' => __('Philippines'), 'PN' => __('Pitcairn'), 'PL' => __('Poland'), 'PT' => __('Portugal'), 'PR' => __('Puerto Rico'), 'QA' => __('Qatar'), 'RE' => __('Reunion'), 'RO' => __('Romania'), 'RU' => __('Russia'), 'RW' => __('Rwanda'), 'ST' => __('São Tomé and Príncipe'), 'BL' => __('Saint Barthélemy'), 'SH' => __('Saint Helena'), 'KN' => __('Saint Kitts and Nevis'), 'LC' => __('Saint Lucia'), 'SX' => __('Saint Martin (Dutch part)'), 'MF' => __('Saint Martin (French part)'), 'PM' => __('Saint Pierre and Miquelon'), 'VC' => __('Saint Vincent and the Grenadines'), 'WS' => __('Samoa'), 'SM' => __('San Marino'), 'SA' => __('Saudi Arabia'), 'SN' => __('Senegal'), 'RS' => __('Serbia'), 'SC' => __('Seychelles'), 'SL' => __('Sierra Leone'), 'SG' => __('Singapore'), 'SK' => __('Slovakia'), 'SI' => __('Slovenia'), 'SB' => __('Solomon Islands'), 'SO' => __('Somalia'), 'ZA' => __('South Africa'), 'GS' => __('South Georgia/Sandwich Islands'), 'KR' => __('South Korea'), 'SS' => __('South Sudan'), 'ES' => __('Spain'), 'LK' => __('Sri Lanka'), 'SD' => __('Sudan'), 'SR' => __('Suriname'), 'SJ' => __('Svalbard and Jan Mayen'), 'SE' => __('Sweden'), 'CH' => __('Switzerland'), 'SY' => __('Syria'), 'TW' => __('Taiwan'), 'TJ' => __('Tajikistan'), 'TZ' => __('Tanzania'), 'TH' => __('Thailand'), 'TL' => __('Timor-Leste'), 'TG' => __('Togo'), 'TK' => __('Tokelau'), 'TO' => __('Tonga'), 'TT' => __('Trinidad and Tobago'), 'TN' => __('Tunisia'), 'TR' => __('Turkey'), 'TM' => __('Turkmenistan'), 'TC' => __('Turks and Caicos Islands'), 'TV' => __('Tuvalu'), 'UG' => __('Uganda'), 'UA' => __('Ukraine'), 'AE' => __('United Arab Emirates'), 'GB' => __('United Kingdom (UK)'), 'US' => __('United States (US)'), 'UM' => __('United States (US) Minor Outlying Islands'), 'UY' => __('Uruguay'), 'UZ' => __('Uzbekistan'), 'VU' => __('Vanuatu'), 'VA' => __('Vatican'), 'VE' => __('Venezuela'), 'VN' => __('Vietnam'), 'VG' => __('Virgin Islands (British)'), 'VI' => __('Virgin Islands (US)'), 'WF' => __('Wallis and Futuna'), 'EH' => __('Western Sahara'), 'YE' => __('Yemen'), 'ZM' => __('Zambia'), 'ZW' => __('Zimbabwe'), ); } // Shortcode that displays a country dropdown add_shortcode ('countries', 'countries_dropdown' ); function countries_dropdown() { $html = '<select name="input-country" id="input-country" class="form-control form-control-alternative"> <option value="">'.__('Select a country / region…').'</option>'; foreach ( get_all_countries() as $code => $name ) { $html .= sprintf('<option value="%s">%s</option>', $code, $name ); } return $html . '</select>'; } 用途: 在 WordPress 帖子/页面编辑器中,在某些小部件中:[countries]; 在 PHP 文件中:echo do_shortcode('[countries]');

回答 0 投票 0

Wordpress 如何添加所有国家/地区

选择国家/地区... <select name="input-country" id="input-country" class="form-control form-control-alternative"> <option value="">Select a country / region…</option> <option value="AF">Afghanistan</option> <option value="AX">Åland Islands</option> <option value="AL">Albania</option> </select> 有没有更短的方法而不是一一写下<option value="AL">Albania</option>值? 以下自定义短代码将显示国家/地区下拉列表: // Utility function: Return an array of countries (code / name pairs) function get_all_countries() { return array( 'AF' => __('Afghanistan'), 'AX' => __('Åland Islands'), 'AL' => __('Albania'), 'DZ' => __('Algeria'), 'AS' => __('American Samoa'), 'AD' => __('Andorra'), 'AO' => __('Angola'), 'AI' => __('Anguilla'), 'AQ' => __('Antarctica'), 'AG' => __('Antigua and Barbuda'), 'AR' => __('Argentina'), 'AM' => __('Armenia'), 'AW' => __('Aruba'), 'AU' => __('Australia'), 'AT' => __('Austria'), 'AZ' => __('Azerbaijan'), 'BS' => __('Bahamas'), 'BH' => __('Bahrain'), 'BD' => __('Bangladesh'), 'BB' => __('Barbados'), 'BY' => __('Belarus'), 'PW' => __('Belau'), 'BE' => __('Belgium'), 'BZ' => __('Belize'), 'BJ' => __('Benin'), 'BM' => __('Bermuda'), 'BT' => __('Bhutan'), 'BO' => __('Bolivia'), 'BQ' => __('Bonaire, Saint Eustatius and Saba'), 'BA' => __('Bosnia and Herzegovina'), 'BW' => __('Botswana'), 'BV' => __('Bouvet Island'), 'BR' => __('Brazil'), 'IO' => __('British Indian Ocean Territory'), 'BN' => __('Brunei'), 'BG' => __('Bulgaria'), 'BF' => __('Burkina Faso'), 'BI' => __('Burundi'), 'KH' => __('Cambodia'), 'CM' => __('Cameroon'), 'CA' => __('Canada'), 'CV' => __('Cape Verde'), 'KY' => __('Cayman Islands'), 'CF' => __('Central African Republic'), 'TD' => __('Chad'), 'CL' => __('Chile'), 'CN' => __('China'), 'CX' => __('Christmas Island'), 'CC' => __('Cocos (Keeling) Islands'), 'CO' => __('Colombia'), 'KM' => __('Comoros'), 'CG' => __('Congo (Brazzaville)'), 'CD' => __('Congo (Kinshasa)'), 'CK' => __('Cook Islands'), 'CR' => __('Costa Rica'), 'HR' => __('Croatia'), 'CU' => __('Cuba'), 'CW' => __('Curaçao'), 'CY' => __('Cyprus'), 'CZ' => __('Czech Republic'), 'DK' => __('Denmark'), 'DJ' => __('Djibouti'), 'DM' => __('Dominica'), 'DO' => __('Dominican Republic'), 'EC' => __('Ecuador'), 'EG' => __('Egypt'), 'SV' => __('El Salvador'), 'GQ' => __('Equatorial Guinea'), 'ER' => __('Eritrea'), 'EE' => __('Estonia'), 'SZ' => __('Eswatini'), 'ET' => __('Ethiopia'), 'FK' => __('Falkland Islands'), 'FO' => __('Faroe Islands'), 'FJ' => __('Fiji'), 'FI' => __('Finland'), 'FR' => __('France'), 'GF' => __('French Guiana'), 'PF' => __('French Polynesia'), 'TF' => __('French Southern Territories'), 'GA' => __('Gabon'), 'GM' => __('Gambia'), 'GE' => __('Georgia'), 'DE' => __('Germany'), 'GH' => __('Ghana'), 'GI' => __('Gibraltar'), 'GR' => __('Greece'), 'GL' => __('Greenland'), 'GD' => __('Grenada'), 'GP' => __('Guadeloupe'), 'GU' => __('Guam'), 'GT' => __('Guatemala'), 'GG' => __('Guernsey'), 'GN' => __('Guinea'), 'GW' => __('Guinea-Bissau'), 'GY' => __('Guyana'), 'HT' => __('Haiti'), 'HM' => __('Heard Island and McDonald Islands'), 'HN' => __('Honduras'), 'HK' => __('Hong Kong'), 'HU' => __('Hungary'), 'IS' => __('Iceland'), 'IN' => __('India'), 'ID' => __('Indonesia'), 'IR' => __('Iran'), 'IQ' => __('Iraq'), 'IE' => __('Ireland'), 'IM' => __('Isle of Man'), 'IL' => __('Israel'), 'IT' => __('Italy'), 'CI' => __('Ivory Coast'), 'JM' => __('Jamaica'), 'JP' => __('Japan'), 'JE' => __('Jersey'), 'JO' => __('Jordan'), 'KZ' => __('Kazakhstan'), 'KE' => __('Kenya'), 'KI' => __('Kiribati'), 'KW' => __('Kuwait'), 'KG' => __('Kyrgyzstan'), 'LA' => __('Laos'), 'LV' => __('Latvia'), 'LB' => __('Lebanon'), 'LS' => __('Lesotho'), 'LR' => __('Liberia'), 'LY' => __('Libya'), 'LI' => __('Liechtenstein'), 'LT' => __('Lithuania'), 'LU' => __('Luxembourg'), 'MO' => __('Macao'), 'MG' => __('Madagascar'), 'MW' => __('Malawi'), 'MY' => __('Malaysia'), 'MV' => __('Maldives'), 'ML' => __('Mali'), 'MT' => __('Malta'), 'MH' => __('Marshall Islands'), 'MQ' => __('Martinique'), 'MR' => __('Mauritania'), 'MU' => __('Mauritius'), 'YT' => __('Mayotte'), 'MX' => __('Mexico'), 'FM' => __('Micronesia'), 'MD' => __('Moldova'), 'MC' => __('Monaco'), 'MN' => __('Mongolia'), 'ME' => __('Montenegro'), 'MS' => __('Montserrat'), 'MA' => __('Morocco'), 'MZ' => __('Mozambique'), 'MM' => __('Myanmar'), 'NA' => __('Namibia'), 'NR' => __('Nauru'), 'NP' => __('Nepal'), 'NL' => __('Netherlands'), 'NC' => __('New Caledonia'), 'NZ' => __('New Zealand'), 'NI' => __('Nicaragua'), 'NE' => __('Niger'), 'NG' => __('Nigeria'), 'NU' => __('Niue'), 'NF' => __('Norfolk Island'), 'KP' => __('North Korea'), 'MK' => __('North Macedonia'), 'MP' => __('Northern Mariana Islands'), 'NO' => __('Norway'), 'OM' => __('Oman'), 'PK' => __('Pakistan'), 'PS' => __('Palestinian Territory'), 'PA' => __('Panama'), 'PG' => __('Papua New Guinea'), 'PY' => __('Paraguay'), 'PE' => __('Peru'), 'PH' => __('Philippines'), 'PN' => __('Pitcairn'), 'PL' => __('Poland'), 'PT' => __('Portugal'), 'PR' => __('Puerto Rico'), 'QA' => __('Qatar'), 'RE' => __('Reunion'), 'RO' => __('Romania'), 'RU' => __('Russia'), 'RW' => __('Rwanda'), 'ST' => __('São Tomé and Príncipe'), 'BL' => __('Saint Barthélemy'), 'SH' => __('Saint Helena'), 'KN' => __('Saint Kitts and Nevis'), 'LC' => __('Saint Lucia'), 'SX' => __('Saint Martin (Dutch part)'), 'MF' => __('Saint Martin (French part)'), 'PM' => __('Saint Pierre and Miquelon'), 'VC' => __('Saint Vincent and the Grenadines'), 'WS' => __('Samoa'), 'SM' => __('San Marino'), 'SA' => __('Saudi Arabia'), 'SN' => __('Senegal'), 'RS' => __('Serbia'), 'SC' => __('Seychelles'), 'SL' => __('Sierra Leone'), 'SG' => __('Singapore'), 'SK' => __('Slovakia'), 'SI' => __('Slovenia'), 'SB' => __('Solomon Islands'), 'SO' => __('Somalia'), 'ZA' => __('South Africa'), 'GS' => __('South Georgia/Sandwich Islands'), 'KR' => __('South Korea'), 'SS' => __('South Sudan'), 'ES' => __('Spain'), 'LK' => __('Sri Lanka'), 'SD' => __('Sudan'), 'SR' => __('Suriname'), 'SJ' => __('Svalbard and Jan Mayen'), 'SE' => __('Sweden'), 'CH' => __('Switzerland'), 'SY' => __('Syria'), 'TW' => __('Taiwan'), 'TJ' => __('Tajikistan'), 'TZ' => __('Tanzania'), 'TH' => __('Thailand'), 'TL' => __('Timor-Leste'), 'TG' => __('Togo'), 'TK' => __('Tokelau'), 'TO' => __('Tonga'), 'TT' => __('Trinidad and Tobago'), 'TN' => __('Tunisia'), 'TR' => __('Turkey'), 'TM' => __('Turkmenistan'), 'TC' => __('Turks and Caicos Islands'), 'TV' => __('Tuvalu'), 'UG' => __('Uganda'), 'UA' => __('Ukraine'), 'AE' => __('United Arab Emirates'), 'GB' => __('United Kingdom (UK)'), 'US' => __('United States (US)'), 'UM' => __('United States (US) Minor Outlying Islands'), 'UY' => __('Uruguay'), 'UZ' => __('Uzbekistan'), 'VU' => __('Vanuatu'), 'VA' => __('Vatican'), 'VE' => __('Venezuela'), 'VN' => __('Vietnam'), 'VG' => __('Virgin Islands (British)'), 'VI' => __('Virgin Islands (US)'), 'WF' => __('Wallis and Futuna'), 'EH' => __('Western Sahara'), 'YE' => __('Yemen'), 'ZM' => __('Zambia'), 'ZW' => __('Zimbabwe'), ); } // Shortcode that displays a country dropdown add_shortcode ('countries', 'countries_dropdown' ); function countries_dropdown() { $html = '<select name="input-country" id="input-country" class="form-control form-control-alternative"> <option value="">'.__('Select a country / region…').'</option>'; foreach ( get_all_countries() as $code => $name ) { $html .= sprintf('<option value="%s">%s</option>', $code, $name ); } return $html . '</select>'; } 用途: 在 WordPress 帖子/页面编辑器中,在某些小部件中:[countries]; 在 PHP 文件中:echo do_shortcode('[countries]');

回答 0 投票 0

在 WooCommerce 中处理指定时间段内客户总支出的退款

使用获取客户 1 年内在 WooCommerce 中的总支出中的代码。 // 实用函数:获取一段时间内特定状态下的客户订单总金额 功能

回答 1 投票 0

Visual Composer 自定义短代码模板 - custom_markup 显示用户输入

我创建了一些短代码元素。现在我想在后端编辑器中自定义元素的外观。 从VC-Pagebuilder wiki的描述中,我发现我可以使用“

回答 2 投票 0

获取客户 1 年内在 WooCommerce 中的总支出

使用根据用户在 WooCommerce 中的总支出显示自定义文本中的代码: add_shortcode('user_total_spent', 'get_user_total_spent'); 函数 get_user_total_spent( $atts ) { 提取(

回答 1 投票 0

获取客户 1 年内在 WooCommerce 中的总支出

使用根据用户在 WooCommerce 中的总支出显示自定义文本中的代码: add_shortcode('user_total_spent', 'get_user_total_spent'); 函数 get_user_total_spent( $atts ) { 提取(

回答 1 投票 0

do_shortcode 不考虑 woocommerce 本机产品短代码的价格过滤器

我的插件中有一些这样的过滤器 add_filter('woocommerce_product_get_price', 'custom_price', 99, 2 ); add_filter('woocommerce_product_get_regular_price', 'custom_price', 99, 2 ); 添加_...

回答 1 投票 0

如何使用 wordpress 和 woocommerce 用短代码显示类别名称?

我正在尝试填写类别描述/文本,并根据您所在的类别页面更改类别名称。 例如这个类别的描述: 您正在观看[类别]。 如果你...

回答 2 投票 0

从 WooCommerce 中的短代码保存自定义结帐字段

使用 WooCommerce,我在将自定义字段中的值保存到数据库中时遇到一些问题。我遵循了几个指南,但由于某种原因它对我不起作用。 这是我添加到我的

回答 1 投票 0

显示 WooCommerce 当前产品类别或标签的短代码

我想制作两个短代码来显示 Woocommerce 产品。 简码 1: 显示 Woocommerce 当前的产品标签。 标签必须是链接。 标签必须用 分隔, 简码...

回答 1 投票 0

显示 WooCommerce 当前产品类别或标签的短代码

我想制作两个短代码来显示 Woocommerce 产品。 简码 1: 显示 Woocommerce 当前的产品标签。 标签必须是链接。 标签必须用 分隔, 简码...

回答 1 投票 0

在任何主题中显示 WooCommerce 产品类别缩略图的短代码

我想用简短的代码在我的类别页面上显示类别缩略图。原谅我,我的PHP技术很差...... 关于系统: WordPress 6.4.3 woocommerce 8.6.1 主题:Div...

回答 1 投票 0

短代码生成“更新失败。响应不是有效的 JSON 响应。”

我正在努力创建一个短代码来从具有特定标签的帖子中提取图像。 此代码一直有效,但现在失败,并显示“更新失败。响应不是有效的 J...

回答 2 投票 0

为什么 WooCommerce 短代码 [product_categories] 属性 id 不返回任何内容?

我试图使用 elementor 插入 woocommerce 短代码 [product_categories ids="27"],id 27 是从编辑类别 url 中找到的,例如: mysite/wp-admin/term.php?taxonomy=

回答 2 投票 0

$atts 是用户输入,如何在 WordPress 中清理和转义

我在 WordPress 中创建了一个短代码。简码代码如下: 函数 wp_test_shortcode($atts){ $atts = Shortcode_atts(数组( 'id' => '测试', '拇指' => '' ),$att...

回答 1 投票 0

Wordpress 表单简码

我已经为 WP 中的表单创建了一个简码。现在我需要使其动态化并为帖子和分类法添加带有 的 标签。 函数简码_形式(){ $表格=“ 我已经为 WP 中的表单创建了一个简码。现在我需要使其动态化,并为帖子和分类添加 <select> 标签和 <options>。 function shortcode_form(){ $form = "<form method='post'> <select name='escape-date' id='escape-date' required> /* NEED TO ADD FUNCTION AND LOGIC TO DISPLAY POSTS */ </select> <select name='escape-date' id='escape-date' required> /* NEED TO ADD FUNCTION AND LOGIC TO DISPLAY TAXONOMIES ASSOCIATED WITH SELECTED POST ABOVE */ </select> </form>"; return $form; } 有两个问题: 1 - $form 是一个 string,所以我无法在其中添加函数。我有哪些选择? 2 - 更改第二个 <select>。这只能用 JS 才能实现吗? 您可以使用以下内容填充 <select> 的帖子列表: /** @var wpdb $wpdb */ global $wpdb; $posts = query_posts(['post_type' => 'post', 'nopaging' => true]); $posts_options_tags = array_map( function ( $post ) { return "<option value='{$post->ID}'>{$post->post_title}</option>"; }, $posts ); $posts_options_tags = implode('', $posts_options_tags); $form = "<form method='post'> <select name='post_id' id='post_id' required> <option>Select a post</option> $posts_options_tags </select> <select name='escape-date' id='escape-date' required> /* NEED TO ADD FUNCTION AND LOGIC TO DISPLAY TAXONOMIES ASSOCIATED WITH SELECTED POST ABOVE */ </select> </form>";

回答 0 投票 0

Woocommerce 产品类型简码

在 woocommerce 短代码中按类型过滤产品的语法是什么?我尝试了以下操作但未成功。 [产品product_type =“简单”per_page =“12”列=“3”] 和 [产品类型=“

回答 1 投票 0

添加 Wordpress 短代码以返回空格分隔的 slugs,并对单词大小写进行自定义更改

我尝试组合我的短代码: add_shortcode( 'MARKE', 'marke_shortcode' ); 函数 marke_shortcode() { $terms = get_the_terms( get_the_ID(), 'marken'); 返回 ucwords($terms[1]->slug)...

回答 2 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.