WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Stop WP from opening links in new window (17 posts)

  1. randyttp
    Member
    Posted 2 years ago #

    WordPress keeps opening all internal links in a new window.

    It might be because my custom template is using $_SERVER[document root] so I can load some inc files.

    Is there any simple setting I can switch to ensure it opens everything in same window?

  2. randyttp
    Member
    Posted 2 years ago #

    Bump

  3. sarahfrantz
    Member
    Posted 2 years ago #

    Does it do it when you absolutely link to something?

  4. randyttp
    Member
    Posted 2 years ago #

    It opens all links in a new page. Even clicking on a post title for example, will open the post in a new window.

    [No bumping, please.]

  5. Curtiss Grymala
    Member
    Posted 2 years ago #

    It sounds like your theme is using the target attribute on any links it outputs.

  6. esmi
    Forum Moderator
    Posted 2 years ago #

    Have you tried:

    - deactivating all plugins to see if this resolves the problem. If this works, re-activate the plugins one by one until you find the problematic plugin(s).

    - switching to the Twenty Eleven theme to rule out any theme-specific problems.

    - resetting the plugins folder by FTP or PhpMyAdmin. Sometimes, an apparently inactive plugin can still cause problems.

  7. randyttp
    Member
    Posted 2 years ago #

    Yeah when I switched to the twenty eleven theme the problem was fixed, so its definitely theme specific.

    And like I stated in my custom theme I did include

    <?php $root = realpath($_SERVER["DOCUMENT_ROOT"]); ?>
    So this way I can pull inc files from the root directory

    and I'm using this

    <base href="http://localhost/wordpress/" />
    <base target="_blank" />

    to read my images files etc cause I have WP installed in the directory of localhost/wordpress/blog

    hmm I just had a thought, I will try stripping each one of those elements out and seeing whats causing it.

  8. esmi
    Forum Moderator
    Posted 2 years ago #

    Using $_SERVER["DOCUMENT_ROOT"] is not good practice and could even create security issues on your site.

  9. randyttp
    Member
    Posted 2 years ago #

    ohh durrr...

    I see the problem. I need to set it to
    <base target="_self" />

    lol sorry guys. and thanks for the help to weeding down the issue.

  10. randyttp
    Member
    Posted 2 years ago #

    esmi... what do you recommend doing instead?

  11. esmi
    Forum Moderator
    Posted 2 years ago #

    Well, what are these files that you want to include? What is their purpose and why do they have to be in the root folder?

  12. randyttp
    Member
    Posted 2 years ago #

    Well I have an HTML/CSS website and then I have wordpress in the blog sub folder. On my top level index file I just call the WP header so I can run the loop and display the posts on the front page.

    But I created a custom theme to match the exact look so when people click on the post title etc it has the same feel.

    Anyhow I want to run some of the same header/nav footers etc so I just inc the same file on both my top level index pages and in the WP custom theme folder... I'm just starting out so I don't really know the best way to lay this out. What would you recommend?

  13. esmi
    Forum Moderator
    Posted 2 years ago #

    You'd need to style the posts on the front page via your main site's CSS but once you get into single Posts & Pages, they should automatically pick up the theme's own CSS (in fact that's what most people don't want). Could it be that you're approaching the theme coding incorrectly and perhaps over-complicating things for yourself?

    I want to run some of the same header/nav footers etc

    Where are these files from? Your main site or the WP theme?

  14. randyttp
    Member
    Posted 2 years ago #

    I switched things around and got rid of $_SERVER["DOCUMENT_ROOT"]
    so hopefully that improves my security and functionality.

    I'm sure I am approaching lots of things incorrectly as this is my first venture into WP. But its working.

    Essentially what I'm doing is building a website and incorporating WordPress into it, not the other way around. That does seem to be the odd way of doing things, but to me its more intuitive and with more control.
    Basically I'm using wordpress more as minimal CMS then as a blog.

    if you goto mysite.com you will be at my main page index, which is just pure HTML5/CSS, however it does grab posts a loops them on the front page.
    Then if you goto mysite.com/blog you will finally be in the directory where my WP is installed. However I'm still using my own theme that is more like once again incorporating WordPress into that theme rather than the other way around. So both my top level index and my subfolder WP have the exact same layout and run off the same CSS.
    My "theme" is very bare but pretty functional. I'm just barely adding single.php comments.php etc.

    So in your opinion is this messed up or what? lol

  15. esmi
    Forum Moderator
    Posted 2 years ago #

    It all sounds OK. Do you still have the new window issue on links? If so, can we see a page with one of these links on?

  16. randyttp
    Member
    Posted 2 years ago #

    Hey esmi

    nope I found the answer to the link problem with my base tag

    I had
    <base target="_blank" />

    and I needed this lol
    <base target="_self" />

    Anyhow thank you for your help and your suggestions :)

  17. Mex Ale
    Member
    Posted 2 years ago #

    Hi, I am facing almost the same problem and trying to get help from many websites no response yet.

    Suddenly all my links started opening in new window. Even the custom menu one. I had deactivated all the plugins to see, but no use.

    Can you please help me. I will really appreciate that since no one is replying me till yet!

    Thanks

    http://www.topgradepapers.com

    if you click on any link it opens in new window :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.