我在PHP中使用此代码:
$idcat = 147;
$thumbnail_id = get_woocommerce_term_meta( $idcat, 'thumbnail_id', true );
$image = wp_get_attachment_url( $thumbnail_id );
echo '<img src="'.$image.'" alt="" width="762" height="365" />';
Run Code Online (Sandbox Code Playgroud)
其中147是当前的ID手动设置,但我需要在其他类别电流id
有什么建议?
我正在开发OSX,我的一个Subversion工作副本刚开始为所有命令返回以下错误,但我的其他结帐工作正常.我同时使用Brew安装的SVN二进制文件以及我的Cornerstone客户端获得相同的消息,但其他工作目录也没问题.
> svn update
svn: E155036: Please see the 'svn upgrade' command
svn: E155036: Working copy '/working_directory' is an old development version (format 12); to upgrade it, use a format 18 client, then use 'tools/dev/wc-ng/bump-to-19.py', then use the current client
> svn upgrade
svn: E155019: Can't upgrade '/working_directory' as it is not a pre-1.7 working copy directory
svn: E150000: Missing default entry
Run Code Online (Sandbox Code Playgroud)
我的bump-to-19.py计算机上没有任何脚本(根据find / -type f -name bump-to-19.py),但我认为我能够在Apache存储库中找到它.也就是说,我不熟悉它的作用或如何使用它.理想情况下,我可以避免签出此工作目录的新版本并手动合并我的所有(许多)更改.
唯一的信息,我能找到是与Netbeans的和javahl,而我既没有使用.
编辑 …
为了在WordPress网站(http://www.example.com)上进行本地开发,我之前就像这样覆盖了WP_SITEURL和WP_HOME值wp-config.php:
define('WP_SITEURL', 'http://local-example/');
define('WP_HOME', 'http://local-example/');
Run Code Online (Sandbox Code Playgroud)
这将允许我将数据库和站点文件复制到本地服务器,并根据需要进行修改,在本地安装上进行测试.
然后有必要将安装转换为WordPress多站点,以便在主站点和托管在子域(http://second.example.com)上的辅助站点之间共享用户,身份验证,插件等.
上面覆盖wp_options表中的值的方法不再有效,但我不确定为主要和子域wp_blogs的wp_2_options表以及表设置值的正确方法.
更新我的HOSTS文件有点是一种解决方法,但它并不理想(我无法与实时网站进行比较等).运行脚本来更改数据库值是我尝试过的另一个选项,但稍微麻烦一点,所以我的问题是MultiSite中是否有一个选项可以在设置文件中覆盖这些值,例如wp-config.php,如果是这样的话看起来像.
一些背景故事(与我的问题没有直接关系,但也许其他人可以使用我的方法)
我正在使用插件高级自定义字段在WordPress v3.9.1中工作.我已经从WordPress中需要格式化的旧数据库中导入了自定义值的CSV文件(使用WP Ultimate CSV Importer插件,免费版本),但有一个例外 - ACF Repeater Fields.该插件很棒,但还没有一种很好的导入数据的方法.
Repeater字段存储在数据库中,如下所示:
meta_id post_id meta_key meta_value
3894 4697 beds 2
3895 4697 _beds field_53bcfe244a98d
4051 4697 _beds_0_other field_53c2273053218
4050 4697 beds_0_other 1
4051 4697 _beds_1_other field_53c2273053218
4050 4697 beds_1_other 3
5894 4698 beds 2
5895 4698 _beds field_53bcfe244a98d
5051 4698 _beds_0_other field_53c2273053218
5050 4698 beds_0_other 1
5051 4698 _beds_1_other field_53c2273053218
5050 4698 beds_1_other 3
Run Code Online (Sandbox Code Playgroud)
那是; 对于每个post_id,有一个称为"床"的Repeater字段."在"中继器字段是1个字段,重复两次.每个字段有2个数据库条目 - 字段引用(用于管理保存字段 - 每个字段始终相同)和值.不像设置那样直观,但它是围绕WordPress的默认表系统设计的.
实际问题
现在,我有从我的旧数据库导入的字段,如下所示:
meta_id post_id meta_key meta_value
#### 4697 beds 2 …Run Code Online (Sandbox Code Playgroud) 我有一个场景,我试图查询具有两个关联表(引用和用户)的父表(文档),它们彼此没有关系,但与父表有关系。在 SQL 中,这个查询看起来像这样并正确输出我正在寻找的数据:
select *
from `document`
left join `user`
on `document`.`user_id` = `user`.`user_id`
left join `reference`
on `document`.`reference_id` = `reference`.`reference_id`
where `user`.`organization_id` = 1;
Run Code Online (Sandbox Code Playgroud)
但是,嵌套的关联必须按层次顺序关联,以便查询工作。由于嵌套关联彼此不相关,因此出现关联错误。我怎样才能避免这个错误?请问required: false对此有何影响?
models.Document.findAll({
order: 'documentDate DESC',
include: [{
model: models.User,
where: { organizationId: req.user.organizationId },
include: [{
model: models.Reference,
}]
}],
})
Run Code Online (Sandbox Code Playgroud)
错误:
未处理的拒绝错误:引用与用户无关!
协会:
Document:
associate: function(db) {
Document.belongsTo(db.User, {foreignKey: 'user_id'}),
Document.belongsTo(db.Reference, { foreignKey: 'reference_id'});;
}
Run Code Online (Sandbox Code Playgroud)
Reference:
associate: function(db){
Reference.hasMany(db.Document, { foreignKey: 'reference_id' });
}
Run Code Online (Sandbox Code Playgroud)
我应该只链接查询吗?
我想排序以下名称
Array ( [Jessie] => 2 [Sarah] => 3 [Simon] => 2 [John] => 2 [Kevin] => 1 [Canvasser] => 8 [canvasser] => 11 )
Run Code Online (Sandbox Code Playgroud)
基于与它们对应的值
我通过以下功能打印了名称
// get canvasser individual names and count houses canvassed
foreach ($canvassers as $key => $value) {
// Add to the current group count if it exists
if ( isset( $canvasser_counts[$value] ) ) {
$canvasser_counts[$value]++;
}
// or initialize to 1 if it doesn't exist
else {
$canvasser_counts[$value] = 1;
}
}
print_r($canvasser_counts);
Run Code Online (Sandbox Code Playgroud)
$ …
我有返回int值的方法,我想检查方法是否返回任何值,我该怎么做?
我试着像下面那样用大于但是我不确定这是正确的方法,因为我正在检查特定> 0但不是如果方法返回任何值.
if (Type.FixedLength() > 0) {
//do something...
}
Run Code Online (Sandbox Code Playgroud)
最好的祝福
我创建了一个简单的 WordPress 插件。为了在页面上显示它,我使用它来调用函数
function facebook_live_counter_main_content(){
[html markups here]
add_action ('wp_head', 'facebook_live_counter_main_content');
Run Code Online (Sandbox Code Playgroud)
可以正常工作了 但我只想显示插件操作主页。我需要您的帮助,如何调用仅显示插件操作主页的功能。
问候-
费萨尔·伊姆兰
有没有办法通过sequelize中的原始插入查询返回插入的行?
该returning选项不会更改返回值中的任何内容。返回插入行的计数和一个空数组而不是插入的行:[ [], 1 ]
let contato = await sequelize.query(
'INSERT INTO public.contato(nome, telefone, id_empresa, id_status) VALUES ($nome, $telefone, $id_empresa, $id_status);',
{
bind: {
nome: form.nome,
telefone: form.telefone,
id_empresa: filaChat.id_empresa,
id_status: 1,
},
type: QueryTypes.INSERT,
returning: true,
}
);
Run Code Online (Sandbox Code Playgroud) 我有两个模型:User和Images。用户有profile_image_id列。
当我得到用户时,include {model:Images, as:'profileImage', attributes:['filename']}我得到profileImage具有filenameas属性的对象。
Sequelize中是否有办法将“文件名”作为用户模型的属性?执行的意义
SELECT u.id, u.name, i.filename
FROM users u
LEFT JOIN images i ON i.id = u.profile_image_id
WHERE u.id = 1
Run Code Online (Sandbox Code Playgroud)
现在起作用的是在用户上定义VIRTUAL属性profileImageFIlename,然后在afterFind用户模型的功能中填充它。但这似乎是很多额外的工作和不必要的数据。
除了原始查询,还有更好的方法吗?
wordpress ×4
sequelize.js ×3
mysql ×2
node.js ×2
php ×2
arrays ×1
associations ×1
cornerstone ×1
java ×1
macos ×1
plugins ×1
postgresql ×1
sorting ×1
sql ×1
svn ×1
thumbnails ×1
woocommerce ×1