I am enqueuing stylesheet main while my images are not showing - html

I am converting HTML to Wordpress theme. I am enqueuing stylesheet. but some of the images are not showing.
Maybe its could be subfolder issue

It is almost certainly a pathing issue -- without being able to see any of your file structure or code, I suspect get_template_directory_uri() is the missing piece. Here's a simplified example of what you need to do.
function itc_wp_enqueue_scripts() {
wp_enqueue_style('bootstrap-style', get_template_directory_uri() . '/css/bootstrap.min.css');
}
add_action('wp_enqueue_scripts', 'itc_wp_enqueue_scripts');
You should replace itc_ with your own prefix on the function name.

Related

wordpress - site not update after update style.css

When I updated the style.css in Appearance > Theme Editor > stylesheet(style.css),
I refresh my site, then I see that the style is not applied.
I've also tried clear cache in browser and use cmd + shift + r to re-download the resources but still not working.
Is there any way to make the site live for development, or is there any preferred way for development?
In style.css
...
/*
Author: xxx Limited
Description: This is the template for xxx
Version: 1.0.0. // tried to update the version here but not working
...
*/
.....
Need to check few things.
upload style.css through ftp or cpanel again to check whether it is properly saved or not,
Remove cache , check in private window to make sure that there is no cache.
check in console for error if above 2 doesn't work.
If the CSS file has been updated, the problem is because of caching. There are different levels of cache.
Clear Cloudflare cache if you are using it.
Clear any caching mechanism that your Webhosting offered.
Clear all plugins cache
Salman and PHP Geek are right, do the steps they mention that should solve your problem. If the problem continues then...
In function.php find wp_enqueue_style function it would look something like this. There can be multiples of them so look for the 'style.css' inside them
wp_enqueue_style('yourtheme-style', get_template_directory_uri() . '/style.css', '', '1.1.0');
see the last argument '1.1.0' this could be anything on your case, this can also be a variable. Change this to something else like '1.1.1' (anything other then 1.1.0)
OR
replace the line with the below code (doing this will change your version automatically whenever you change something in the style.css)
$ver = filemtime(get_template_directory().'/style.css');
wp_enqueue_style('yourtheme-style', get_template_directory_uri() . '/style.css', '', $ver);

HTML anchors not working on server

My links to anchors aren´t working and I don´t know why. I guess it is something about the server where I have my site uploaded.
I tested my page on a free server and localhost and there are no troubles, it only happens on the server. Any idea why this might be happening?
The sidebar at the right contains the links that get you to spots on the same page, just works once, but when the page finish loading, doesn't work anymore
This is the page:
http://www.fumigacionesmillenium.com.ve/
I am inspecting the source and JS console, there seems to be lots of JS errors after I click the link on the right. Attaching a screenshot:
i think meta tag is not closing proper.Please check below image
I installed a plugin called Slideshow, i´m using Wordpress, the reason of the error:
TypeError: jQuery.easing[jQuery.easing.def] is not a function
It was a conflict between the Jquery that loads the plugin and the Jquery that loads from functions.php, solved it this way:
code before:
if( !is_admin()){
wp_deregister_script('jquery');
wp_enqueue_script( 'material-jquery', 'http://code.jquery.com/jquery-2.1.3.min.js', array(), '1.0', false );
}
code after:
if( !is_admin()){
wp_deregister_script('jquery');
wp_register_script('jquery', ("http://code.jquery.com/jquery-2.1.3.min.js"), false, '2.1.3');
wp_enqueue_script( 'jquery');
}
Now i can use the plugin without problems, and my anchors are working perfectly.

Yii2 add google font to head

I was wondering how do you add link tag/google font to head in yii2.
I want to add the following
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700' rel='stylesheet' type='text/css'>
I have found this documentation but doesn't mention anything about link/adding google font etc
The correct answer is to create a new AssetBundle.
While you can directly place the HTML for the fonts into the of your main.php file, this isn't the Yii way. If you have tried to load jQuery files this way, you might notice odd behavior when directly putting them into the HTML.
For example: Directly place the HTML tag for Bootstrap CDN into the head of your main.php. Then, somewhere in your code try to use the tooltip. You will get an error in your console that tooltip is not a function. - This is because the way Yii puts all your template files together, and at that time, Bootstrap is not available.
While simply loading a font probably won't cause any problems, it is a good idea to do things the way they were intended. Following MVC rules, properly documenting your code, and following the Yii best practices, will go a long way. Not only will you thank yourself a year later when you have to go back into a project, but the next guy will appreciate it. I can't stand going into systems, and seeing stuff thrown everywhere, chincy hacks, and spaghetti code, and no documentation or comments.
Correct Way:
Create a new AssetBundle. In your assets folder, you probably already have AppAsset.php. Duplicate it, and name it FontAsset.php.
Here is an example from my project, using 3 Google fonts.
FontAsset.php
<?php
namespace app\assets;
use yii\web\AssetBundle;
class FontAsset extends AssetBundle
{
public $basePath = '#webroot';
public $baseUrl = '#web';
public $css = [
'//fonts.googleapis.com/css?family=Open+Sans:400,700',
'//fonts.googleapis.com/css?family=Ubuntu:400,700',
'//fonts.googleapis.com/css?family=Oswald:400,700'
];
public $cssOptions = [
'type' => 'text/css',
];
}
In your layout, main.php for example. Right under where you see AppAsset::register($this)
main.php
use app\assets\FontAsset;
FontAsset::register($this);
For every layout file that you want to load those fonts, include the FontAsset.
The AssetBundle is basically a bundle of CSS and/or JS files and options. You could add another one for say JWPlayer say named VideoAsset, and add your JS/CSS files for JWPlayer in it.
Point being, you shouldn't be adding these things directly into the HTML of the layouts directly, as it can cause problems. Let the AssetManager handle them by declaring AssetBundles.
It might save you later down the road!
The best way is to create an asset bundle and add the link to the bundle.
You can find a complete guide here:
http://www.yiiframework.com/doc-2.0/guide-structure-assets.html
You can put it directly in the head of the layout (file views/layouts/main.php)

wp_enqueue_style Does Not Behave As Documented

I have the following written in a driver:
add_action( 'wp_enqueue_scripts', 'add_css_file' );
function add_css_file()
{
// Tried this prior:
// $path = ABSPATH . "/wp-content/plugins/this_plugin/css/";
// wp_register_style( 'css_file', $path.'css_file.css' );
wp_register_style( 'css_file', 'http://subdomain.mysite.com/wp-content/plugins/this_plugin/css/css_file.css' );
wp_enqueue_style( 'css_file' );
}
The string "css_file" does not appear in the View Source HTML and the CSS rules defined therein do not take effect.
Have you included wp_head() in the <head> of your page? wp_head() will add your queued styles and scripts to the page.
The problem for me lay in the fact that I am modifying the Admin screen rather than the display of a Page or Post to viewers.
Replace:
wp_enqueue_script(...)
With:
admin_enqueue_script(...)
Best of luck.
I have just tried this snippet in my site, and it is working properly. You may get conflict with some other plugin/code.
Also make sure you don't have any Cache enabled, and if so, try to clean up the cache. Also try to clean out your browser cache.
Finally, if non of the above works for you, try to de-activate your plugins, one by one in order to see if some of the plugins conflicts with this function, and in last step try to change theme, also to make sure the current theme doesn't conflict with this function.

Using dependencies in wp_register_style() for wordpress

I am trying to get a custom css file to load after the plugin stylesheets. I was thinking I could use the $deps parameter of wp_register_style(), but the css file does not load at all when I add the array(). This happens no matter what is included in the $deps array(), ie (array('style')
, array('style.css')).
Is there an issue with the call, or a better way of doing this?
In my functions.php
// Load custom css
add_action('wp_enqueue_scripts', 'prefix_add_my_stylesheet');
function prefix_add_my_stylesheet() {
wp_register_style( 'custom-supersized-styles', get_template_directory_uri(). '/css/custom-supersized-styles.css', array('style','supersized');
wp_enqueue_style( 'custom-supersized-styles' );
}
If you're using the WP Supersized plugin try registering your function like so:
// Load custom css
add_action('wp_enqueue_scripts', 'prefix_add_my_stylesheet', 999);
The dependencies array (the parameter you're attempting to use to add supersized with) depends on supersized having already been registered by WordPress. If you set the priority of your own prefix_add_my_stylesheet to a higher number, it should then load after the plugin has registered and loaded its CSS (and thus will be available).
In addition, you can remove the style as a dependency. (style is never registered by WordPress as a dependency handler, and your enqueued scripts / css should be loading after style.css loads anyway).
Hope that helps!