Title: URL logic problem
Last modified: November 7, 2022

---

# URL logic problem

 *  Resolved [andrewpko](https://wordpress.org/support/users/andrewpko/)
 * (@andrewpko)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/url-logic-problem/)
 * Hello. I found that url logic don`t work. In your script(/includes/conditional-
   logic/class-wpcode-conditional-page.php) I found function which return URL to
   compare. And it return nothing. $wp in this function is empty. print_r($wp) in
   this function return nothing.
 *     ```
       public function get_page_url() {
       return isset( $wp->request ) ? trailingslashit( home_url( $wp->request ) ) : '';
       }
       ```
   
 * I changed this function this way and its work fine:
 *     ```
       public function get_page_url() {
       return isset( $wp->request ) ? trailingslashit( home_url( $wp->request ) ) : $_SERVER['REQUEST_URI'];
       }
       ```
   
 * **Is there more proper way to solve this problem? Maybe you can make update?**
    -  This topic was modified 3 years, 7 months ago by [andrewpko](https://wordpress.org/support/users/andrewpko/).
    -  This topic was modified 3 years, 7 months ago by [andrewpko](https://wordpress.org/support/users/andrewpko/).

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Mircea Sandu](https://wordpress.org/support/users/gripgrip/)
 * (@gripgrip)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/url-logic-problem/#post-16172426)
 * Hi [@andrewpko](https://wordpress.org/support/users/andrewpko/),
 * From what you are describing it sounds like you are trying to run the snippet
   conditional logic before the $wp object has been loaded.
 * Thank you for you detailed suggestion – we will look into adding the request_uri
   as a fallback for the next release.
 *  Thread Starter [andrewpko](https://wordpress.org/support/users/andrewpko/)
 * (@andrewpko)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/url-logic-problem/#post-16172449)
 * Thanks for answer. How can I run snippet conditional logic after the $wp object
   has been loaded? I use autoload, frontend only.
    -  This reply was modified 3 years, 7 months ago by [andrewpko](https://wordpress.org/support/users/andrewpko/).

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘URL logic problem’ is closed to new replies.

 * ![](https://ps.w.org/insert-headers-and-footers/assets/icon-256x256.png?rev=2758516)
 * [WPCode - Insert Headers and Footers + Custom Code Snippets - WordPress Code Manager](https://wordpress.org/plugins/insert-headers-and-footers/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/insert-headers-and-footers/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/insert-headers-and-footers/)
 * [Active Topics](https://wordpress.org/support/plugin/insert-headers-and-footers/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/insert-headers-and-footers/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/insert-headers-and-footers/reviews/)

## Tags

 * [logic](https://wordpress.org/support/topic-tag/logic/)
 * [url](https://wordpress.org/support/topic-tag/url/)

 * 2 replies
 * 2 participants
 * Last reply from: [andrewpko](https://wordpress.org/support/users/andrewpko/)
 * Last activity: [3 years, 7 months ago](https://wordpress.org/support/topic/url-logic-problem/#post-16172449)
 * Status: resolved