Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum url changes

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

  • Robin W
    Moderator

    @robin-w

    I’d suspect that because each forum is not an real individual wordpress page (ie not in dashboard>pages) , then retrieving the page_link might well return a ‘virtual’ ID, and this might be the top forum – not proven, just a hunch.

    My initial suggestions would be that you try get_permalink instead of get_page_link() – this retrieves the full url of the current displayed page, and should in theory get you what you want.

    If you need the existing get_page_link() for your other pages, you could try wrapping it in an if… eg:

    if (is_bbpress()) {
    get_permalink etc.
    }
    else {
    get_page_link()
    }

    Let us know if that helps


    pawanahluwalia
    Participant

    @pawanahluwalia

    Thanks!

    However, is_bbpress() only seems to be true if you are on the root forum page.

    How can I test for any forum page?

    I tried

    echo get_permalink();

    on a forum page, but it does not display anything. It does display it on the root forum page, but it does not match the root forum page permalink. It again shows the highest Forum ID permalink instead.

    Presumably the page is being created in code and is overwriting the content of the current forum page.

    Any further suggestions?


    Robin W
    Moderator

    @robin-w

    if get_page link returns :

    mywebsite.com/forum_name3/forum_name3/

    then you could just test for this eg

    if (get_page_link() == 'mywebsite.com/forum_name3/forum_name3/')  {
    get_permalink etc.
    }
    else {
    get_page_link()
    }

    pawanahluwalia
    Participant

    @pawanahluwalia

    The only trouble with this solution is, it is not permanent. You would need to the change the code each time a new forum is added.


    Robin W
    Moderator

    @robin-w

    would you like to post your current code?


    pawanahluwalia
    Participant

    @pawanahluwalia

    I don’t think that is necessary. Using the example you have used above, you would have to change the bold part each time a new forum is added.

    if (get_page_link() == ‘mywebsite.com/forum_name3/forum_name3/’)

    How could this be avoided?


    Robin W
    Moderator

    @robin-w

    ok, I had understood that get_page_link() returned mywebsite.com/forum_name3/forum_name3/ in all cases

    is this not correct?


    pawanahluwalia
    Participant

    @pawanahluwalia

    I haven’t tried adding an extra forum to test it. I am just assuming it defaults to the highest forum ID, which is what it is currently doing.


    Robin W
    Moderator

    @robin-w

    ok, not sure there’s much more I can do to help in that case 🙂


    pawanahluwalia
    Participant

    @pawanahluwalia

    How do we address this question to the plugin authors?


    Robin W
    Moderator

    @robin-w

    what is the question ?


    pawanahluwalia
    Participant

    @pawanahluwalia

    My original questions above.


    Robin W
    Moderator

    @robin-w

    sorry, I have given you some code which addresses, which does not seem to satisfy you.

    I am not quite sure why you think the plugin authors would want to make their plugin work for your exact circumstances, but if you want to post a defect then go here

    https://bbpress.trac.wordpress.org/


    pawanahluwalia
    Participant

    @pawanahluwalia

    I am just trying to understand how the plugin works and why the php code is not giving the correct url that matches what is visible in the browser. I have tried your suggestions but I still can’t determine why the urls being generated by either get_page_link() or get_permalink() are different to the ones being displayed in the browser address line.


    Robin W
    Moderator

    @robin-w

    ok, so this is the first time you have said that the get_permalink does not match the display.

    so for a forum as a specific example, please state

    the displayed url
    the get_page_link
    the get_permalink


    pawanahluwalia
    Participant

    @pawanahluwalia

    I mentioned I had tried get_permalink() above, below the post where you first suggested it and said it didn’t match.

    This is what I am getting on the root forum page:

    the displayed url: mywebsite.com/qaforums/
    the get_page_link: mywebsite.com/forum_name3/
    the get_permalink: mywebsite.com/qaforums/forum/forum_name3/

    However, when I try and view these on any subpages of mywebsite.com/qaforums/, nothing is returned. I don’t know why.


    pawanahluwalia
    Participant

    @pawanahluwalia

    I have managed to analyse the subpage urls further and have verified that get_permalink() gives the correct urls which matches the browser address line.

    get_page_link() doesn’t do this.

    So thanks for suggesting to use get_permalink() instead of get_page_link().

    But I still don’t know why it is not doing the same thing on the forum root page.


    Robin W
    Moderator

    @robin-w

    ok you could also use a PHP variable rather than a wordpress function

    so

    $current_url = $_SERVER['REQUEST_URI'];

    should give you the displayed URL in all cases.

    you can then do an ‘if’ test to see if you are in forums using say

    if (strpos($_SERVER['REQUEST_URI'], '/qaforums/') == true ) …then you are in the forums


    pawanahluwalia
    Participant

    @pawanahluwalia

    Thank you, that works perfectly! 🙂

    Thank you for your patience and help. I really appreciate it!


    Robin W
    Moderator

    @robin-w

    great – glad we got there !!

Viewing 20 replies - 1 through 20 (of 20 total)
  • You must be logged in to reply to this topic.
Skip to toolbar