WordPress企业主题定制/开发/优化

wordpress wp_logout_url登出函数

首页 » WORDPRESS主题技术 » wordpress wp_logout_url登出函数

用法:
<?php echo wp_logout_url$redirect ); ?>

参数:
redirect
(string) (可选) 当登出的时候转到的URL
默认无

示例:
默认跳转页: 
<a href="<?php echo wp_logout_url(); ?>" title="Logout">Logout</a>

跳转到当前页:
<a href="<?php echo wp_logout_url( get_permalink() ); ?>" title="Logout">Logout</a>

跳转到首页:
<a href="<?php echo wp_logout_url( home_url() ); ?>" title="Logout">Logout</a>

--------------------------------------
一些常用wordpress判断函数:
--------------------------------------
is_single()
When any single Post page is being displayed. 判断是否是具体文章的页面
is_single(’17′)
When Post 17 is being displayed as a single Post. 判断是否是具体文章(id=17)的页面
is_single(’Beef Stew’)
When the Post with Title “Beef Stew” is being displayed as a single Post. 判断是否是具体文章(标题判断)的页面
is_single(’beef-stew’)
When the Post with Post Slug “beef-stew” is being displayed as a single Post. 判断是否是具体文章(slug判断)的页面

comments_open()
When comments are allowed for the current Post being processed in the WordPress Loop. 是否留言开启
pings_open()
When pings are allowed for the current Post being processed in the WordPress Loop. 是否开启ping

is_page()
When any Page is being displayed. 是否是页面
is_page(’42′)
When Page 42 is being displayed. 同single,id判断,即是否是id为42的页面
is_page(’About Me’)
When the Page with Title “About Me” is being displayed. title判断
is_page(’about-me’)
When the Page with Page Slug “about-me” is being displayed. slug判断

is_category()
When any Category archive page is being displayed. 是否是分类
is_category(’6′)
When the archive page for Category 6 is being displayed. 同single,id判断,即是否是id为6的分类
is_category(’Cheeses’)
When the archive page for the Category with Name “Cheeses” is being displayed. title判断
is_category(’cheeses’)
When the archive page for the Category with Category Slug “cheeses” is being displayed. slug判断
in_category(’5′)
Returns true if the current post is in the specified category id. read more (http://codex.wordpress.org/Template_Tags/in_category) 判断当前的文章是否属于分类5

is_author()
When any Author page is being displayed. 将所有的作者的页面显示出来
is_author(’1337′)
When the archive page for Author number 1337 is being displayed. 显示author number为1337的页面
is_author(’Elite Hacker’)
When the archive page for the Author with Nickname “Elite Hacker” is being displayed. 通过昵称来显示当前作者的页面
is_author(’elite-hacker’)
When the archive page for the Author with Nicename “elite-hacker” is being displayed.

下面是通过不同的判断实现以年、月、日、时间等方式来显示归档
is_date()
When any date-based archive page is being displayed (i.e. a monthly, yearly, daily or time-based archive).
is_year()
When a yearly archive is being displayed.
is_month()
When a monthly archive is being displayed.
is_day()
When a daily archive is being displayed.
is_time()
When an hourly, “minutely”, or “secondly” archive is being displayed.

判断当前是否是归档页面
is_archive()
When any type of Archive page is being displayed. Category, Author and Date based pages are all types of Archives.

判断是否是搜索
is_search()
When a search result page archive is being displayed.

判断页面是否404
is_404()
When a page displays after an “HTTP 404: Not Found” error occurs.

判断是否翻页,比如你当前的blog是http://domain.com 显示http://domain.com?paged=2的时候,这个判断将返回真,通过这个函数可以配合is_home来控制某些只能在首页显示的界面,
例如:if(is_home() && !is_paged() )
is_paged()
When the page being displayed is “paged”. This refers to an archive or the main page being split up over several pages. This does not refer to a Post or Page whose content has been divided into pages using the QuickTag.

is_attachment()
When an attachment document to a post or Page is being displayed. An attachment is an image or other file uploaded through the post editor’s upload utility. Attachments can be displayed on their own ‘page’ or template. For more information, see Using Image and File Attachments.

is_feed()
When the site requested is a Syndication. This tag is not typically used by users; it is used internally by WordPress and is available for Plugin Developers.

is_trackback()
When the site requested is WordPress’ hook into its Trackback engine. This tag is not typically used by users; it is used internally by WordPress and is available for Plugin Developers.

is_user_logged_in()
判断是否登录

相关项目

  • WordPress外贸企业主题

  • 最近更新

  • 热门标签