我的wordpress上有这个类别:
Test1
- Sub1OfTest1
- Sub2OfTest1
Test2
- Sub1OfTest2
- Sub2OfTest2
Run Code Online (Sandbox Code Playgroud)
现在http://localhost/wordpress/category/test1
我在网址:我在文件上写下面的代码category-test1.php
<?php
$categories = get_categories('child_of=2');
print_r($categories);
foreach ($categories as $category) : ?>
<div class="qitem">
<a href="<?php get_category_link( $category->term_id ); ?>" title="<?php echo $category->name; ?>">
<?php echo $category->name; ?>
</a>
<h4>
<span class="caption">
<?php echo $category->name; ?>
</span>
</h4>
<p>
<span class="caption">
<?php echo $category->description; ?>
</span>
</p>
</div>
<?php
endforeach;
?>
Run Code Online (Sandbox Code Playgroud)
我正在尝试显示Test1的子类别,但代码只返回array().我错过了什么?
<?php
if ( function_exists('has_nav_menu') && has_nav_menu('primary-menu') ) {
wp_nav_menu( array( 'sort_column' => 'menu_order', 'container' => 'ul', 'menu_id' => 'main-nav', 'menu_class' => 'nav fl', 'theme_location' => 'primary-menu' ) );
} else {
?>
Run Code Online (Sandbox Code Playgroud)
我正在尝试在我functions.php的Woothemes Canvas的孩子主题中添加Wordpress菜单管理的二级菜单.我认为有一种方法可以将它添加到上面的数组中,但我无法让它工作.思考?
我正在使用自定义模板显示博客帖子列表,因为,我使用home.php文件来显示自定义主页.我使用query_posts()它是一个自定义模板.我使用自定义blog Home模板在wp admin中创建了一个页面.一切都好.但是read more..在使用时我无法获得工作链接the_content('read more..')
当我使用the_content('read more..')整个帖子内容显示后不切断它<!--more-->也,阅读更多链接没有显示.
我通读了wp codex http://codex.wordpress.org/Function_Reference/query_posts,甚至重置global $more为0
这是我正在使用的页面模板.http://pastebin.com/VTvN5dtT
我究竟做错了什么??请帮忙.
我在worpress头版工作.
我想手动在特定位置向页面添加插件,但我自己将代码添加到页面中.
我基本上想要在特定位置的某个页面中包含一个插件.所以我创建了一个div ...
<div id="plugin-holder">
**Plugin-will-appear-here-with-this-code**
</div>
Run Code Online (Sandbox Code Playgroud)
请问有谁知道怎么做?
谢谢
我是WordPress的新手.我为视频创建了自定义帖子类型,但我不知道如何在页面中显示帖子类型.例如,我希望当用户添加视频时,他不必在发布视频时选择视频模板,当他们打开已发布的视频时,页面会打开视频播放器而不是打开页面.我想要一个像视频播放器准备好的自定义页面,我所要做的就是给视频播放器提供视频的网址.已经有了视频播放器的代码.我怎样才能做到这一点?
我需要你的帮助以下内容.
我为我的页面设置的功能图像不会显示在页面本身中.是否有任何插件或我可以做的事情,以便让我为帖子和页面设置的特色图像显示在相应的条目中?
任何建议都非常感谢!
我正在努力让WordPress分页工作.
我使用了不同的插件,并尝试调整pagination.php函数中的代码无济于事.
无论到目前为止我使用过什么插件或调整,第2页,第3页等都会显示相同的帖子.
这是pagination.php中的代码
<!-- Previous / More Entries -->
<div class="mdnw_pagination">
<?php if(function_exists('wp_paginate')) :
wp_paginate();
; else : ?>
<div class="p button"><?php next_posts_link(__('« Previous Posts', 'skeleton')); ?></div>
<div class="m button"><?php previous_posts_link(__('Next Posts »', 'skeleton')); ?></div>
<?php endif; ?>
</div>
<!-- </Previous / More Entries -->
Run Code Online (Sandbox Code Playgroud)
以下是主页的博客模板的代码:
<!-- THE POST QUERY -->
<?php
wp_reset_query();
global $paged;
global $template_file;
$cat_string = '';
$format = '';
if( get_post_custom_values('blog_post_count') ) :
$post_array = get_post_custom_values('blog_post_count');
$post_count = join(',', $post_array);
else :
$post_count = -1; …Run Code Online (Sandbox Code Playgroud) 我正在尝试为Wordpress创建自定义网站主题,我遇到了一些问题.我在网站的页眉和页脚部分使用两个完全相同的菜单.
调用
wp_nav_menu(array('theme_location' => 'header'));
Run Code Online (Sandbox Code Playgroud)
在header.php中运行良好,菜单打印出来没有任何问题,但如果我在footer.php文件中执行相同操作,则菜单不会打印并var_dump(wp_nav_menu(array('theme_location' => 'header')));打印为false.
我尝试了一些我在Google上找到的修改functions.php文件的解决方法,但是没有一个能帮助我解决这个问题.我的functions.php文件现在只包含一行
register_nav_menus( array( 'header' => 'Header menu', 'footer' => 'Footer menu' ) );
Run Code Online (Sandbox Code Playgroud)
是的,我试着用
wp_nav_menu(array('theme_location' => 'footer'))
Run Code Online (Sandbox Code Playgroud)
同样的,结果相同.如果我从header.php调用相同的函数
wp_nav_menu(array('theme_location' => 'footer'))
Run Code Online (Sandbox Code Playgroud)
菜单很好用.
在一个简单的WordPress插件中,我/user/user_id使用以下代码将commenter链接重定向到URL :
define('PROFILE', '<a href="/user/%d">%s</a>');
function my_get_comment_author_link($comment_ID) {
global $comment;
return sprintf(PROFILE, $comment->user_id,
$comment->comment_author);
}
add_action('get_comment_author_link',
'my_get_comment_author_link');
Run Code Online (Sandbox Code Playgroud)
我怎么能显示一个简单的公共用户配置文件(对于所有注册用户而不仅仅是作者)在该URL上显示用户名?
我想我应该在我的2013年主题中创建一个PHP脚本 -
<?php
/* Template Name: Public User Profile */
?>
<?php get_header(); ?>
<?php
$my_query = new WP_Query($args);
// somehow get the user ID out of URL?
// somehow get the WP_User object?
printf('<p>Name: %s</p>', $user->display_name);
?>
<?php get_footer(); ?>
Run Code Online (Sandbox Code Playgroud)
但是当重新获得URL时,如何使WordPress执行该PHP脚本/user/user_id?
我应该在这里使用Rewrite API以及如何使用?我尝试了以下,但没有看到任何影响:
add_rewrite_rule('/user/(\d+)',
'index.php?XXX=$matches[1]',
'top'
);
flush_rewrite_rules();
Run Code Online (Sandbox Code Playgroud)
或者我错过了什么,也许我应该首先添加自定义帖子类型?(如你所见 - 我很困惑,"迷失在文档中").
更新:
我可以覆盖 …
我是显示帖子类别子列表.列表显示所有我需要显示只有6(孩子)帮助我们...
ex:menu(父)list1(child)list2(child)list3(child)list4(child)list5(child)list6(child)list7(child)list8(child)
<?php $article_categories = get_categories(array(
'child_of' => get_category_by_slug('work')->term_id
));
$talentChildren = get_categories(array('child_of' => get_category_by_slug('talent')->term_id));
?>
<?php if ( have_posts()) : ?>
<?php $talent_Children = array($talentChildren[0]); ?>
<?php foreach($talent_Children as $talent): ?>
<?php
$talentSubChildren = new WP_Query();
$talentSubChildren->query(array('category_name' => $talent->slug));
?>
<h2><a href="<?php the_permalink() ?>talent/directors/"><?php echo $talent->name; ?></a></h2>
<ul>
<?php while ($talentSubChildren->have_posts()) : $talentSubChildren->the_post(); ?>
<li>
<h4><a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
</h4>
</li>
<?php endwhile; ?>
</ul>
<?php endforeach; ?>
<?php endif; ?>
</div>
Run Code Online (Sandbox Code Playgroud)