gpt4 book ai didi

wordpress - Fishpig Magento 模块 : How to get data from postmeta table?

转载 作者:行者123 更新时间:2023-12-03 01:55:23 24 4
gpt4 key购买 nike

我有带有 Fishpig_Wordpress 模块的 Magento。我为帖子创建了一些新的 postmeta 数据,这些数据保存在 postmeta 表中。我刚刚看到 Fishpig 在/Model/Mysql4/Post.php 中有一个自定义加载 SQL 方法..

protected function _getLoadSelect($field, $value, $object)
{
$select = $this->_getReadAdapter()->select()
->from(array('e' => $this->getMainTable()))
->where("e.{$field}=?", $value);

if (Mage::getDesign()->getArea() == 'frontend') {
if (Mage::helper('wordpress/plugin_allInOneSeo')->isEnabled()) {
foreach(Mage::helper('wordpress/plugin_allInOneSeo')->getMetaFields() as $field) {
$table = 'aioseop_'.$field;
$select->joinLeft(
array($table => Mage::helper('wordpress/db')->getTableName('postmeta')),
"{$table}.post_id = e.ID AND ".$this->_getReadAdapter()->quoteInto("{$table}.meta_key=?", "_aioseop_{$field}"),
array('meta_'.$field => 'meta_value')
);
}
}
}

$select->limit(1);

return $select;
}

它在 joinLeft 方法中使用 Mage::helper('wordpress/db')->getTableName('postmeta') 。但我不知道是否应该使用 _getLoadSelect protected 方法或创建另一个类来调用 postmeta 表。

所以,问题是:有没有办法使用 Fishpix 模块从 postmeta 表获取数据,或者我需要为此创建一个新类?

最佳答案

对于现在阅读本文的任何人,您可以使用以下代码检索 postmeta 值:

<?php echo $post->getMetaValue('your_meta_key') ?>

同样的方法可用于任何具有元表(帖子、页面、评论、用户等)的 WordPress 实体

关于wordpress - Fishpig Magento 模块 : How to get data from postmeta table?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11316058/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com