2016-11-07 145 views
1

我是新来的Wordpress,所以请忍受我在这里。Wordpress功能停止页面渲染

我导航到另一个页面,从一个WordPress页面以下链接:

<a href="<?php echo site_url(); ?>/wp-content/themes/woffice-child-theme/page-templates/loginF.php"><img src="./wp-content/themes/woffice-child-theme/page-templates/images/signin-btn.png"></a> 

loginF.php做负载,但在任何地方的页面我叫喜欢HOME_URL任何WordPress的()的函数或wp_login_form( )页面停止呈现。例如,如果我将home_url()放在页面的开头,那么我会在浏览器中看到一个空白页面。这是为什么发生?我以某种方式离开wordpress上下文吗?该怎么办?

这里是loginF.php:

<html> 

<?php 
    $redirect_url = home_url(); 

?> 

    <head> 
    <title>Title</title> 
    <meta charset="UTF-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
    <link rel="stylesheet" type="text/css" href="/wp-content/themes/woffice-child-theme/page-templates/style2.css"> 
    <link href="https://fonts.googleapis.com/css?family=Lato:300,400,700" rel="stylesheet"> 
    <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,300' rel='stylesheet' type='text/css'> 
    </head> 
    <body> 

    <div class="frontpage-content">  
     <div class="front-wrap"> 
     <br/> 
     <div class="new-login-logo text-center"><img src="/wp-content/themes/woffice-child-theme/page-templates/images/new-login-logo.png"></div> 
     <br/><br/> 
     <div class="frontpage-fields"> 
      <input type="text" name="log" id="user" class="input" placeholder="Email Address"> 
      <input type="password" name="pwd" id="pass" class="input" placeholder="Password"> 
     </div> 
     <div class="forgot-password-new"><a href="#">Forgot your password?</a></div> 
     <br/> 
     <div class="text-center"><a href="#"><img src="./images/captcha-image.png"></a></div> 
     <br/> 
     <div class="text-center new-login-space"><a href="#"><img src="/wp-content/themes/woffice-child-theme/page-templates/images/new-login-btn.png"></a></div> 



     </div> 
    </div> 

    </body> 
</html> 

回答

0

按照WordPress标准创建一个新的页面模板。

<?php 
/** 
* Template Name: My Custom Page 
*/ 
get_header(); ?> 

<!-- Your code goes here --> 

<?php get_footer(); ?> 

https://developer.wordpress.org/themes/template-files-section/page-template-files/page-templates/

然后创建一个从WordPress的一个新的页面后端,并选择你的页面模板名称在后端&另存为模板(模板名称在你的模板文件中的标头调用之前给出)这一页。

在发布按钮下面的页面属性部分,我们可以选择页面模板。

Screenshot attached

末,把这种新的页面URL中的锚标记为href值,而不是调用模板文件。

我们可以从页面标题或页面slu get中获取页面URL。

get_permalink(get_page_by_path('your-page-slug')) 

get_permalink(get_page_by_title('Your page title')) 
0

这是整个页面的html?它应与

<?php get_header(); ?> 

开始和

<?php get_footer(); ?> 
+0

已添加,但情况相同。 – user3151013

0

最后,您应该分配你的页面模板在WordPress的任何页面,然后使用页面的网址,而不是目前使用的。目前您正在使用错误的方式。请纠正它。另外不要忘记在模板中调用get_header()和get_footer()。

+0

如何将页面模板分配给我的页面? – user3151013

+0

http://www.hongkiat.com/blog/wordpress-custom-loginpage/ –

0

好吧,也许我们可以用另一种方式来。您的链接链接到页面模板,而不是有点古怪的URL。也许这会导致Wordpress变得困惑并进入无限循环。

请问你为什么试图链接到这个?是否需要定制样式的登录页面,因为还有其他解决方案。

你可以通过把这段代码在你的主题的functions.php

// log in logo link 
    add_filter('login_headerurl', 'custom_loginlogo_url'); 
     function custom_loginlogo_url($url) { 
     return 'http://www.yourlink.co.uk'; 
    } 
    // login logo 
    function my_login_logo() { ?> 
     <style type="text/css"> 
     body.login div#login h1 a { 
      background-image: url(<?php echo get_stylesheet_directory_uri(); ?>/library/images/logo.png); 
      padding-bottom: 15px; 
      height: 74px; 
      width: auto; 
      background-size: 60% auto; 
     } 
     </style> 
    <?php } 
    add_action('login_enqueue_scripts', 'my_login_logo'); 

改变正常的WordPress登录页面上的标识然后只是链接到www.yourdomain.co.uk/wp-admin

但是,如果你要使用自定义登录页面,使用模板文件,目前的工作,这应该这样开这样的

<?php /* Template Name: my-template */ ?> 

,包括在该网页。然后在Wordpress管理中创建一个页面,并选择模板“my-template”,并链接到该页面的URL。

+0

是它的自定义登录页面。如何去整合它一些其他方式? – user3151013