如何判断WordPress登录用户的角色
先判断下是否登录,然后获取当前用户对象,然后获取当前用户对象的信息,需要哪些用哪些:if(is_user_logged_in()){$current_user = wp_get_current_user();/*** @example Safe usage: $current_user = wp_get_current_user();* if ( !($current_user instanceof WP_User) )* return;*/echo 'Username: ' . $current_user->user_login . '';echo 'User email: ' . $current_user->user_email . '';echo 'User first name: ' . $current_user->user_firstname . '';echo 'User last name: ' . $current_user->user_lastname . '';echo 'User display name: ' . $current_user->display_name . '';echo 'User ID: ' . $current_user->ID . '';}不了解再问。
祝愉快!
wordpress后台登陆地址,怎么进入WordPress后台
wordpress中添加了分类目录,菜单里面的分类目录不显示的原因:没有添加文章。
添加一篇文章即可。
WordPress网站在菜单里添加分类目录的方法:1. wordpress是制作网站的一种工具,首先要有自己的wordpress。
然后进入的wordpress选择文章下的分类目录选项。
2. 点击下面的“添加新分类目录”。
3. 然后选择“外观”里的“菜单”,这个菜单就是以后网站上面横条显示目录的地方。
4. 然后看到左下角。
分类目录 里,点击查看所有会看到所有以前添加过的目录都在里面。
此时选择 “诗歌” 然后选择“添加至菜单”诗歌目录就进入了菜单里面了。
5. 登陆自己的网站,看登陆看效果,而且排在最后一个,想排在前面,在菜单那里是可以改顺序的。
进去就能看到。
wordpress站内公告工具怎么用
把这个代码放入你主题的functions.php 中,不过在这里建议大家最好是放在另一个文件中,这样以后比较好查找和修改。
还有一点就是函数命名要唯一,不然会和其他函数命名一样而报错。
也可以加上if ( !function_exists('my_test') ) {} 来判断是否存在这个方法,如果存在将不会运行。
这样可以避免报错!如下:if(is_user_logged_in()){$current_user = wp_get_current_user();/*** @example Safe usage: $current_user = wp_get_current_user();* if ( !($current_user instanceof WP_User) )* return;*/echo 'Username: ' . $current_user->user_login . '';echo 'User email: ' . $current_user->user_email . '';echo 'User first name: ' . $current_user->user_firstname . '';echo 'User last name: ' . $current_user->user_lastname . '';echo 'User display name: ' . $current_user->display_name . '';echo 'User ID: ' . $current_user->ID . '';}
wordpress面包屑导航代码中,如何获取当前文章所属目录的目录title?...
显示或返回当前页面的分类目录标题:1、在这里需要用到函数:single_cat_title()对那些显示WordPress标签而非分类目录标题的页面(如"/tag/carceer"),该标签显示或返回标签名称,该标签只能用在WordPress主循环(loop)之外.其基本用法如下: 其默认用法如下:,'display'=> true ); ?> 2、对其参数进行一些必要的说明:$prefix 输出时在标题前的文本信息,默认值:None,类型是字符串,可选$display 显示标题(TRUE)或返回标题以便用在PHP中(FALSE)。
默认值:TRUE,类型是布尔型 可选下面这个例子在分类目录标题后显示“当前分类:”字样:示例如下://output:当前分类目录是wordpress 3、下面这个例子将当前分类目录标题赋值给变量$current_category以用在PHP中.示例代码如下:
ie无法默认最大化注册表修改不成功[HKEY
最简单的方法是用鼠标放在网页四角上形成箭头后向四角拖成满屏,关闭网页在打开,如果不行多试几回,不行在看下面。
右键单击IE快捷方式(如没有将桌面的IE图标托到快速启动栏中)选“属性”/“快捷方式”在“运行方式”中单击右侧下拉条选“最大化”按确定退出,打开IE点击里面的链接然后关闭。
前面打开的IE浏览窗口,只留下这个链接页面拉动边框,将窗口拉到整个屏幕然后关闭该页面,以后打开IE窗口直接最大化了。
如果还不行,运行输入regedit回车,打开注册表定位[HKEY_CURRENT_USER\Software\Microsoft\InternetExplorer\Desktop\OldworkAreas\]然后在右窗格选中“OldworkAreaRects”将它删除。
在找到[HKEY_CURRENT_USER\Sofware\Microsoft\Internet Explorer\Main]选窗口右侧的“Window Placement”项删除,重启电脑,然后打开IE将窗口最大化,并击“还原”按钮将窗口还原,接着再击“最大化”按钮,最后关闭IE以后在打开IE就正常了。
还是不行还原一下系统或重装。
或下载超级兔子在她的选项中有重装IE,请重装IE。
下载地址: 使用系统自带的系统还原的方法: 系统自带的系统还原:“开始”/“程序”/“附件”/“系统工具”/“系统还原”,点选“恢复我的计算机到一个较早的时间”,按下一步,你会看到日期页面有深色的日期,那就是还原点,你选择后,点击下一步还原(Win7还原系统,在控制面板然后设备和安全子选项然后备份和还原子选项)。
如何获取 WordPress 各类页面的链接
在WordPress项目开发过程,很可能需要获取WordPress 各类页面的链接,包括首页、文章页、Page页面、存档页面等等,今天倡萌就简单分享下获取 WordPress 各类页面的链接的方法。
获取文章或页面链接 直接输出文章或页面的链接: 返回文章或页面的链接,以供调用: get_permalink(); 可以使用 echo 输出,结果和直接使用 the_permalink() 一样: 获取存档页面链接 function get_current_archive_link( $paged = true ) { $link = false; if ( is_front_page() ) { $link = home_url( '/' ); } else if ( is_home() && "page" == get_option('show_on_front') ) { $link = get_permalink( get_option( 'page_for_posts' ) ); } else if ( is_tax() || is_tag() || is_category() ) { $term = get_queried_object(); $link = get_term_link( $term, $term->taxonomy ); } else if ( is_post_type_archive() ) { $link = get_post_type_archive_link( get_post_type() ); } else if ( is_author() ) { $link = get_author_posts_url( get_query_var('author'), get_query_var('author_name') ); } else if ( is_archive() ) { if ( is_date() ) { if ( is_day() ) { $link = get_day_link( get_query_var('year'), get_query_var('monthnum'), get_query_var('day') ); } else if ( is_month() ) { $link = get_month_link( get_query_var('year'), get_query_var('monthnum') ); } else if ( is_year() ) { $link = get_year_link( get_query_var('year') ); } } } if ( $paged && $link && get_query_var('paged') > 1 ) { global $wp_rewrite; if ( !$wp_rewrite->using_permalinks() ) { $link = add_query_arg( 'paged', get_query_var('paged'), $link ); } else { $link = user_trailingslashit( trailingslashit( $link ) . trailingslashit( $wp_rewrite->pagination_base ) . get_query_var('paged'), 'archive' ); } } return $link; } 该函数可以输出首页、分类法(自定义分类法、标签、分类)、自定义文章类型的存档页面、作者存档页面、日期存档页面 的链接,包含分页。
获取当前页面链接 如果你不想判断页面类型,只想输出当前页面的链接,可以使用下面的代码: request)); echo $current_url; ?>
怎样制作wordpress的面包屑导航
如果是新手, 建议用其他Wordpress 的插件。
例如Yoast SEO 或者 WP SEO 他们都有加面包屑的功能, 如果不想加插件, 可以把以下加进function.php // Breadcrumbs function custom_breadcrumbs() { // Settings $separator = '>'; $breadcrums_id = 'breadcrumbs'; $breadcrums_class = 'breadcrumbs'; $home_title = 'Homepage'; // If you have any custom post types with custom taxonomies, put the taxonomy name below (e.g. product_cat) $custom_taxonomy = 'product_cat'; // Get the query & post information global $post,$wp_query; // Do not display on the homepage if ( !is_front_page() ) { // Build the breadcrums echo ''; // Home page echo '' . $home_title . ''; echo ' ' . $separator . ' '; if ( is_archive() && !is_tax() && !is_category() && !is_tag() ) { echo '' . post_type_archive_title($prefix, false) . ''; } else if ( is_archive() && is_tax() && !is_category() && !is_tag() ) { // If post is a custom post type $post_type = get_post_type(); // If it is a custom post type display name and link if($post_type != 'post') { $post_type_object = get_post_type_object($post_type); $post_type_archive = get_post_type_archive_link($post_type); echo 'labels->name . '">' . $post_type_object->labels->name . ''; echo ' ' . $separator . ' '; } $custom_tax_name = get_queried_object()->name; echo '' . $custom_tax_name . ''; } else if ( is_single() ) { // If post is a custom post type $post_type = get_post_type(); // If it is a custom post type display name and link if($post_type != 'post') { $post_type_object = get_post_type_object($post_type); $post_type_archive = get_post_type_archive_link($post_type); echo 'labels->name . '">' . $post_type_object->labels->name . ''; echo ' ' . $separator . ' '; } // Get post category info $category = get_the_category(); if(!empty($category)) { // Get last category post is in $last_category = end(array_values($category)); // Get parent any categories and create array $get_cat_parents = rtrim(get_category_parents($last_category->term_id, true, ','),','); $cat_parents = explode(',',$get_cat_parents); // Loop through parent categories and store in variable $cat_display $cat_display = ''; foreach($cat_parents as $parents) { $cat_display .= ''.$parents.''; $cat_display .= ' ' . $separator . ' '; } } // If it's a custom post type within a custom taxonomy $taxonomy_exists = taxonomy_exists($custom_taxonomy); if(empty($last_category) && !empty($custom_taxonomy) && $taxonomy_exists) { $taxonomy_terms = get_the_terms( $post->ID, $custom_taxonomy ); $cat_id = $taxonomy_terms[0]->term_id; $cat_nicename = $taxonomy_terms[0]->slug; $cat_link = get_term_link($taxonomy_terms[0]->term_id, $custom_taxonomy); $cat_name = $taxonomy_terms[0]->name; } // Check if the post is in a category if(!empty($last_category)) { echo $cat_display; echo 'ID . '">ID . '" title="' . get_the_title() . '">' . get_the_title() . ''; // Else if post is in a custom taxonomy } else if(!empty($cat_id)) { echo '' . $cat_name . ''; echo ' ' . $separator . ' '; echo 'ID . '">ID . '" title="' . get_the_title() . '">' . get_the_title() . ''; } else { echo 'ID . '">ID . '" title="' . get_the_title() . '">' . get_the_title() . ''; } } else if ( is_category() ) { // Category page echo '' . single_cat_title('', false) . ''; } else if ( is_page() ) { // Standard page if( $post->post_parent ){ // If child page, get parents $anc = get_post_ancestors( $post->ID ); // Get parents in the right order $anc = array_reverse($anc); // Parent page loop if ( !isset( $parents ) ) $parents = null; foreach ( $anc as $ancestor ) { $parents .= '' . get_the_title($ancestor) . ''; $parents .= ' ' . $separator . ' '; } // Display parent pages echo $parents; // Current page echo 'ID . '"> ' . get_the_title() . ''; } else { // Just display current page if not parents echo 'ID . '">ID . '"> ' . get_the_title() . ''; } } echo ''; } }
如何解决wordpress管理后台产生过
;echo 'User ID: ' . $current_user->User email: ' . $current_user->echo ''; ;>*/>*** @example Safe usage;user_lastname ;user_email ;>. $current_user->user_firstname . ''';ID ;';Username: ' . $current_user->echo 'if(is_user_logged_in()){$current_user = wp_get_current_user();/user_login ;echo 'display_name . ''';br /...
转载请注明出处51数据库 » wordpress $current_u