得到博客的首页:
<?php echo home_url( '/' ); ?>
得到模板中的CSS文件位置,image 图片的位置
<link href="<?php bloginfo('template_directory'); ?>/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<img src="<?php bloginfo('template_directory'); ); ?>/image/wordpress.png title=”good template” />
<?php wp_enqueue_script("jquery"); ?>
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/my-theme.js"></script>
wp_enqueue_script( 'featured-slider', get_bloginfo('stylesheet_directory') . '/js/featured-slider.js', array( 'jquery', 'jquery-uicore','jquery-ui-tabs' ) );
if( !is_admin() ) {
wp_enqueue_script( 'my-theme', get_bloginfo('stylesheet_directory') .'/js/my-theme.js', $in_footer);
}
相关信息
post-<?php the_ID(); ?>">
<?php the_permalink() ?>">
<?php the_title(); ?>
the_category(", ")?>
the_content()
the_author_meta()
next_post_link() next_post_link("<strong>%title</strong>");
comments_number()
常用的标签(循环)
<?php wp_list_pages('title_li=" ); ?>
<?php wp_get_archives('type=monthly"); ?>
wp_list_categories
显示特定的类别下的文章
<ul class='tocNav">
<?php
global $post;
$myposts = get_posts("numberposts=5&category=3");
foreach($myposts as $post):
setup_postdata($post);
?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>
<!—//end recent
SEO相关的标签
bloginfo() 如 bloginfo("name");
wp_title()wp_title("—",true,"");
the_title() the_title("<h2>", "</h2>");
the_content() the_content("more_link_text", strip_teaser, "more_file");
预定义的CSS
.aligncenter: This style is generated if you select Center. A good way to ensure this style is centered is:
.alignleft
.alignright:
div.aligncenter {
display: block;
margin-left: auto;
margin-right: auto;
}
.alignleft {
float: left;
}
.alignright {
float: right;
}
In addition to the alignment, if you choose to write a caption for your image
.wp-caption: Wraps the image and the caption text in a div which also includes the alignment class from above if you selected one.
.wp-caption-text: Wraps the specific text in a p tag with this class assigned. This class appears inside the outer div with the .wp-caption class assigned to that div, like so:
Classes output by the sidebar widgets
The following classes are output by the various default widgets available in WordPress:
.widget: If you use the standard function to register a sidebar and "widigtize" your theme, this class will be appended to every <li> tag produced by a widget. You can customize the register sidebar function so that this class will not appear.
.textwidget: This class is added to text generated by the Text widget.
.blogroll: This class is generated by the Links widget (your blogroll).
It is added to the main ul wrapper.
.linkcat: This class is added to the <li> of every link that has a href link for a category.
Classes output by the wp_list_pages template tag
.page_item: This is applied to each list item tag in a page list (even page lists generated by the Page widget)
.current_page_item: This class is assigned to the currently selected page.
.current_page_parent: If the currently selected page has a parent page, that parent will have this class appended to it.
.current_page_ancestor
Classes output by the wp_list_categories template tag
.cat-item: This is applied to each li item in a category listing
.current-cat-parent: If a category is nested and selected, this will display in the li item of that parent
body_class class styles
<body <?php body_class(); ?>>
自定义
活动
Creating a custom page template
Creating a second sidebar
Creating a custom page.php template file
自定义的类别页面:
category-2.php
问题是如何在自定义的类别页面中定义自定义的内容页,标签页等
自定义的头部等
Creating custom header, footer, sidebar includes
对于多媒体类型的处理