0

I have got IIS and WAMP running simultaneously. They listen to different ports and everything was fine until I moved a wordpress website from localhost to godaddy. Now when I load http://localhost:8080/wordpress/# (this is the wamp server) all styles are not being loaded. The wordpress website is located in the www folder. I am loading the style sheets with:

<link type="text/css" rel="stylesheet" href="<?php echo trailingslashit( get_bloginfo('template_url') ); ?>style.css" media="screen" />

And the browser renders:

<link type="text/css" rel="stylesheet" href="localhost:8080/wordpress/#/wp-content/themes/ParvanTheme/style.css" media="screen">

The path is correct.

Any idea how to fix that?

I have tried creating a virtual host on apache.

<VirtualHost *:8080> ...

Even though IIS listens to 80 and WAMP to 8080 the virtual host still opens IIS.

Henry Lynx
  • 1,099
  • 1
  • 19
  • 41
  • It is always best to create a Virtual Host especially to run a copy of a live WordPress site [See thsi for help creating a Virtual Host](http://stackoverflow.com/questions/23665064/project-links-do-not-work-on-wamp-server/23990618#23990618) – RiggsFolly Nov 08 '15 at 16:47

1 Answers1

0

The path is not correct, I hardly believe a URL with a hash sign in it does actually link to a physical folder on the server and if it does probably you have some arcane config running which I believe GoDaddy hasn't.

Also, you are not loading stylesheets properly. In Wordpress never, ever input stylesheet manually within the header.php file, you are bypassing the wp_head() function which is there for this specific reason. This can lead you to other endless insane problems in the future.

The correct way to load your stylesheet is to register and enqueue a style file in your functions.php file, inside your theme folder.

You can hook the registration/enqueue to your wp_enqueue_scripts action in this way:

/**
 * Proper way to enqueue scripts and styles
 */
function theme_name_scripts() {
    wp_enqueue_style( 'style-name', get_stylesheet_uri() );
    wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true );
}

add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );

get_stylesheet_uri() points directly to your style.css sitting on the theme folder, if you need to append other CSS files you can follow the example of the JS enqueue.

The Wordpress Codex is your friend, you need more info about the arguments of wp_enqueue_style() you can take a good read on the relative page on the Codex: https://codex.wordpress.org/Function_Reference/wp_enqueue_style

Now, onto your IIS/WAMP problem. If opening the browser at 8080 you can still see the IIS splash page probably is because IIS is already occupying the 8080 port, if this is the case Apache should notify you it could not start because the 8080 is bound to another port in use. I could suggest you to either stop IIS while you're working on WAMP or to move Apache to serve another port not in use on your system.

If all else fails you can configure IIS to run PHP and Wordpress but keep in mind this requires a bit of fiddling on IIS and the .htaccess file here won't work at all (and you need to write manually rules on the web.config file).

MacK
  • 2,132
  • 21
  • 29