WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Widget Context] can't target page by URL (39 posts)

  1. Darrell Schauss
    Member
    Posted 3 years ago #

    I am using WordPress 3.0.1 MU. I try to target a widget by URL so it only shows on that page but it won't show. Nor can I show on all and hide on that URL. It just shows on all. All other options work such as showing on only Single pages.

    I tried full url with http:// and /page/* page/* page/, etc

    http://wordpress.org/extend/plugins/widget-context/

  2. liaaz
    Member
    Posted 3 years ago #

    it works for me
    please don't include the ending slash and than try i.e use only page

  3. TakeoK
    Member
    Posted 3 years ago #

    Thank you! The examples should mention NOT using a trailing slash UNLESS it's being used in combination with a wildcard. I tried everything (or so I thought) and was going mad! I could not get it to work at all. I was using the following:

    programs/ohio/
    programs/ohio/*

    but thanks to this post I tried the below and it now works! Thank you!

    programs/ohio
    programs/ohio/*

  4. farfromfearless
    Member
    Posted 3 years ago #

    I'm trying to use this plugin with WP 3.0 Multisite, but for some reason, the target by url approach isn't working at all. This is my setup:

    1. I have two blogs:
    - http://www.mydomain.com/en/
    - http://www.mydomain.com/fr/

    2. I'm attempting to show a widget *only* on a page as such:
    - http://www.mydomain.com/en/some-page-name/
    - using the following rule in WidgetContext:
    - some-page-name
    - some-page-name/*
    - No such luck.

    3. I have even tried with the following rules:
    - en/some-page-name
    - en/some-page-name/*
    - fr/some-page-name
    - fr/some-page-name/*

    Is this plugin compatible with WP Multisite? I have had great success with it on standalone installations of WP, but this is the first time I've tried using it with MultiSite. Any suggestions would be most welcome.

  5. cedarhs
    Member
    Posted 3 years ago #

    I think it must be something buggy with the plugin (or it has something to do with the WordPress install?).

    It's strange, I was running WordPress 3.0.1 on a Window XP localhost install. This pluging (ver0.7) was working great.

    A coworkder migrated the site to a Server 2003 machine, using IIS, I reinstalled all the plugins I used on the previous box, and now I Widget Context isn't working. All the widgets I want on the front page are there, however, when I select a TEXT box widget, SHOW ON SELECTED (all unchecked) --> TARGET BY URL: http://192.168.150.4:88/wordpress/?page_id=17

    It won't show. I tried many combinations, but this was the format I used on my XP box, and as I said, it worked fine that way.

    I even tried DISPLAY WIDGETS plugin too, and that won't work. I'm guessing it might have something with the IIS configuration?

    I'm curious, are the rest of you also using IIS?

  6. jpmorganjr
    Member
    Posted 3 years ago #

    Sorry I don't know how to update plugins in the wordpress plugin database, but here's a fix:

    In widget-context.php change this function:

    function get_current_url() {
    if ($_SERVER['REQUEST_URI'] == '')
    $uri = $_SERVER['REDIRECT_URL'];
    else
    $uri = $_SERVER['REQUEST_URI'];

    $url = (!empty($_SERVER['HTTPS']))
    ? "http://".$_SERVER['SERVER_NAME'].$uri
    : "http://".$_SERVER['SERVER_NAME'].$uri;

    if (substr($url, -1) == '/')
    $url = substr($url, 0, -1);

    return $url;
    }

    To this one:

    function get_current_url() {
    $uri = $_SERVER['REQUEST_URI'];
    if (substr($uri, -1) == '/') $uri = substr($uri, 0, -1);
    return $uri;
    }

    You won't be able to use the http or https versions of the target by URL anymore, but you shouldn't be able to anyway because all the widgets are on the same domain.

    If I had more time I'd do a proper debug, but I'm in a hurry and wanted to share this because it's the only plugin that offers this solution and I know plenty of others need it to work!!

  7. cedarhs
    Member
    Posted 3 years ago #

    Hi. Thanks for posting this. I wasn't able to get this working based on your code. :(

  8. jpmorganjr
    Member
    Posted 3 years ago #

    What are you entering as the URL(s)?

  9. kongenidalen
    Member
    Posted 3 years ago #

    Finally somebody got it right...Big thank you jpmorganjr
    :-) worked like a charm... show or hide with url entering as follows:
    /blogname/pageid...basicly everything but the http and domain name.
    repeat as many page as you like... Cheers

  10. Hendison Scott
    Member
    Posted 3 years ago #

    Aha! -

    everything but the http and domain name.

    It DOES seem to work correctly. I'm likin' this a lot, it came installed on a new clients site, so just stumbled across it - I'm donating the author something right now, (and you should too) ;)

  11. mrwweb
    Member
    Posted 3 years ago #

    +1 to jpmorganjr. This did fix it.

    Just to be clear for others doing this, the syntax for targeting URLs differs from the widget-context documentation. Instead of "pagename" you enter "/pagename".

    Thanks again!

  12. Subvillain
    Member
    Posted 3 years ago #

    Try */?page_id=123
    or */pagename

  13. jabberjack
    Member
    Posted 3 years ago #

    Nice Plugin - install and it works! Thanks for your coding time! Makes my WPMU site look and run a LOT better.

  14. butnotphilcollinsgood
    Member
    Posted 3 years ago #

    +2 to jpmorganjr. Did the trick. Really appreciate your time and efforts!

  15. nojmike
    Member
    Posted 3 years ago #

    +3 to jpmorganjr. What a hero.

  16. solutionsphp
    Member
    Posted 3 years ago #

    Thanks jpmorganjr! The fix posted got this plugin working for me.

  17. lanceng
    Member
    Posted 3 years ago #

    GREAT PLUGIN!

    Tks!

  18. Zathman
    Member
    Posted 3 years ago #

    +1 to TakeoK
    +4 to jpmorganjr

    Thanks you guys! I was about to yell at someone... :P Now someone is safe.

  19. prestonisgreat
    Member
    Posted 3 years ago #

    Just for my own sanity, I want to double check and make sure I am doing everything correct:

    I changed the code jpmorganjr suggested.

    I am entering the URL like this: /center/facilities_theretreat/ omitting the http and domain name.

    I am clicking on the "Show on selected"

    Am I missing something because it sure isn't working for me... i would love if it would.

  20. jpmorganjr
    Member
    Posted 3 years ago #

    You are welcome everyone!

    Preston, try it without the trailing slash at the end.

    You can try these three options to see if you can get it working:

    /with/trailing/slash/
    /without/trailing/slash
    /with/slash/and/star/*

    Let me know what happens!

  21. Kaspars
    Member
    Posted 3 years ago #

    Just wanted to say a personal thanks to jpmorganjr and TakeoK for helping others get this plugin working. Your assistance here is much appreciated and makes this such a great community!

    Kaspars (author of the plugin)

  22. jpmorganjr
    Member
    Posted 3 years ago #

    Cheers Kaspars. Any chance you can integrate the changes into the actual plugin? I don't know how to do it.

  23. Hendison Scott
    Member
    Posted 3 years ago #

    I would love to see the plugin get updated - It'
    s mandatory on every site we do now...

    Actually, @Kaspars I wonder if you might allow us to integrate your installation with our own plugin? - We've added a couple of other indispensable plugins too (with their permission of course) - http://wordpress.org/extend/plugins/seo-automatic-wp-core-tweaks/

  24. prestonisgreat
    Member
    Posted 3 years ago #

    @jpmorganjr and the winner is "/without/trailing/slash".

    I also added a title to the widget which might have helped it function properly.

    Thanks!

  25. prestonisgreat
    Member
    Posted 3 years ago #

    Also be aware that the "or target by URL" section is case sensitive... The URL has to look exactly like it looks in the web browser.

    (ie. /without/trailing/slash = /without/trailing/slash AND /without/Trailing/Slash = /without/Trailing/Slash)

  26. Jason Paul
    Member
    Posted 2 years ago #

    I'm pretty disappointed that this plugin has stopped working correctly. I can no longer target all posts in a category such as category/books/* (or any variation that you'd think would work). It seems like it's only stopped working after the last update of WordPress.

  27. Hendison Scott
    Member
    Posted 2 years ago #

    Any news or a planned release for .8 version? Maybe making targeting urls simpler?

  28. ned4spd8874
    Member
    Posted 2 years ago #

    +1 to jpmorganjr!

  29. idealform01
    Member
    Posted 2 years ago #

    I can't get target URL to work either, I have tried all of these:

    /legal_education/code-of-best-practices-in-fair-use-for-online-video/
    legal_education/code-of-best-practices-in-fair-use-for-online-video/
    /legal_education/code-of-best-practices-in-fair-use-for-online-video
    legal_education/code-of-best-practices-in-fair-use-for-online-video

    this is the only page I want this widget to show up on but I can't get it working for the life of me. I have nothing selected to the left, the only thing I have selected is "show on selected".

    I have tried with the updated code and with out. I have tried with the full URL and various combinations. I have the latest WP version. I have no idea how to get this working, any help would be greatly appreciated.

    Thanks

  30. ned4spd8874
    Member
    Posted 2 years ago #

    User jpmorganjr's fix and just enter "/code-of-best-practices-in-fair-use-for-online-video" and see if that fixes it for you. What's your site address? That might be helpful if you are still having problems.

Topic Closed

This topic has been closed to new replies.

About this Topic