【发布时间】:2011-11-06 19:57:54
【问题描述】:
如果这是我在 WordPress 中的简码:
[catlist name='mycategory', template='category-display-template' excerpt='yes']
如何获取名称值以显示在我的 WordPress 页面中?我在想<?php echo $name ?>
任何帮助将不胜感激。
插件代码如下所示 - 这是代码的摘录:
function catlist_func($atts, $content = null) {
$atts = shortcode_atts(array(
'id' => '0',
'name' => '',
'category_name' => '',
'orderby' => 'date',
'order' => 'desc',
'numberposts' => '5',
'date' => 'no',
'author' => 'no',
'dateformat' => get_option('date_format'),
'template' => 'default',
'excerpt' => 'no',
'exclude' => '0',
'excludeposts' => '0',
'offset' => '0',
'tags' => '',
'content' => 'no',
'catlink' => 'no',
'comments' => 'no',
'thumbnail' => 'no',
'thumbnail_size' => 'thumbnail',
'post_type' => '',
'post_parent' => '0',
'class' => 'lcp_catlist',
'customfield_name' => '',
'customfield_value' =>'',
'customfield_display' =>'',
'taxonomy' => ''
), $atts);
$catlist_displayer = new CatListDisplayer($atts);
return $catlist_displayer->display();
}
add_shortcode('catlist', array('ListCategoryPosts', 'catlist_func'));
类似于 Oleksandr Bernatskyi 提供的代码
如何在此页面中调用'name' 我已将文本需要调用它放置在下面的代码中我想要插入名称的位置...
$lcp_display_output .= '<a href="'.get_permalink($single).'" title="'.get_the_title($single).'" class="medium magenta awesome">Read More »</a> '.Need to call it here.' <a href="'.get_category_link($single).'" title="'.get_the_title($single).'" class="medium magenta awesome">Category »</a><div class="category-clear"></div>';
或者名称实际上是“页面的类别”
- 如何让名称显示“名称”或“类别名称”
- 如何链接到分类页面?
我正在使用这个 wordpress 插件http://wordpress.org/extend/plugins/list-category-posts/
------------------ 或者我想要完成的简化解决方案可能是这样的 ------
这是我如何在插件中调用函数的简码:
[catlist name='Alfa Romeo' template='category-display-template' excerpt='yes' thumbnail='yes' numberposts='1' author='yes' category_name='Alfa Romeo' URL='http://3d-car-shows.com/category/alfa-romeo/']
[catlist name='BMW' template='category-display-template' excerpt='yes' thumbnail='yes' numberposts='1' author='yes' category_name='BMW' URL='http://3d-car-shows.com/category/bmw/']
现在在插件页面上,如果有一种简单的方法可以从简码中提取手动创建的“类别名称”和“URL”值,我将能够链接到自定义创建的页面...
类似的东西
<a href="<?php echo $category_name ?>"><?php echo $URL ?></a>
谢谢。
【问题讨论】:
-
这个简码是a plugin提供的吗?
-
Wordpress Codex 中有一个关于如何执行此操作的教程。我现在找不到它,但它很好
-
是的,亚当它是插件的一部分
-
Gerald,你是想修改这个插件并打印 $name 值,还是需要在短代码函数之外访问它的值,比如在你的模板代码中?
-
好的,让我看看这个插件。
标签: wordpress