• Resolved randyttp

    (@randyttp)


    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?

Viewing 15 replies - 1 through 15 (of 16 total)
  • Thread Starter randyttp

    (@randyttp)

    Bump

    Does it do it when you absolutely link to something?

    Thread Starter randyttp

    (@randyttp)

    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.]

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

    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.

    Thread Starter randyttp

    (@randyttp)

    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="https://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.

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

    Thread Starter randyttp

    (@randyttp)

    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.

    Thread Starter randyttp

    (@randyttp)

    esmi… what do you recommend doing instead?

    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?

    Thread Starter randyttp

    (@randyttp)

    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?

    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?

    Thread Starter randyttp

    (@randyttp)

    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

    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?

    Thread Starter randyttp

    (@randyttp)

    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 ??

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Stop WP from opening links in new window’ is closed to new replies.