ftwwings on "wp_redirect not working"

ساخت وبلاگ

So i have been trying deferent things of same code, and always retu an error:

Parse error: syntax error, unexpected 'function' (T_FUNCTION) in /home/tzjelenje/tz-jelenje.dreamhosters.com/wp-content/themes/colormag/functions.php on line 3
line 3

in this case is : function redirect_visitors() {

Code is :

add_action( 'init', 'redirect_visitors' )
function redirect_visitors() {
if ( ! is_user_logged_in() && is_front_page() ) {
wp_redirect( 'http://www.tz-jelenje.dreamhosters.com/readme.html', 301 );
exit; } }

Please add semicolon after add_action( 'init', 'redirect_visitors')
So code should be like below:
add_action( 'init', 'redirect_visitors' );
function redirect_visitors() {
if ( ! is_user_logged_in() && is_front_page() ) {
wp_redirect( 'http://www.tz-jelenje.dreamhosters.com/readme.html', 301 );
exit; } }

ftwwings
Member
Posted 18 minutes ago #

did it, there is no error now, but it wont redirect, it just loads.

i added code in root of theme at top of functions.php

ftwwings
Member
Posted 15 minutes ago #

UPDATE : i did remove && is_front_page() from if and it redirects now, but how can i exclude wp-admin from that, so that i can get to login

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 240 تاريخ : پنجشنبه 30 ارديبهشت 1395 ساعت: 19:12