returning page urls
-
I created the code below which works as expected on my test environment, but not in the wordpress.com live site (I have a VIP account). Would differing url structures throw it all off? Also, the date returns the wrong month (both test and live env). I’m passing data from the blog into variables.
if (is_home() && is_paged() == 0) { <–this seems fine
echo ‘var name=”Blog:Home”;’;
echo ‘var prop=”Home”;’;
}
elseif (is_paged() >= 1) {
echo ‘var name=”Blog:’ . get_page_link($page_id) . ‘”;’; <–oddly, this returns the first permalink
echo ‘var prop=”Browse”;’;
}
elseif (is_author()) { <–this seems fine
echo ‘var name=”Blog:’ . $mm_auth . ‘”;’;
echo ‘var prop=”‘ . $mm_auth . ‘”;’;
}
elseif (is_single()) { <–this seems fine
echo ‘var name=”Blog:’ . $author . ‘:’ . $post->post_title . ‘”;’;
echo ‘var prop=”‘ . $author . ‘”;’;
}
elseif (is_search()) { <–this seems fine
echo ‘var name=”Blog:Search:’ . $search . ‘”;’;
echo ‘var prop=”Search”;’;
}
elseif (is_month()) {
$month = get_month_link(”,”);
echo ‘var name=”Blog:’ . $month . ‘”;’; <–this returns wrong month url
echo ‘var prop=”Browse”;’;
}
else { ; } -
-
If anyone else is trying this, I used the following line in place of those that weren’t working:
echo ‘var s_pageName=”Blog:’.$_SERVER[‘REQUEST_URI’].'”‘;case closed.
-
In case anyone comes across this, here is the better way to do it:
echo ‘var s_pageName=”Blog:’.js_escape($_SERVER[‘REQUEST_URI’]).'”;’;now the case is closed. ;)
- The topic ‘returning page urls’ is closed to new replies.