Dashicons in wordpress (frontend) won't display - wordpress

I'm creating a website in WordPress. I'm using dashicons for rating (manually) holidays.
It used to work, but after update the dashicons won't be visible for non-logged in users. Only, if you login, you can see the star ratings.
The star rating should be visible on the left top of each holiday deal.
Who knows a solution?
Website url is www.ikwilopvakantie.nl

Dashicons is the official icon font of the WordPress admin as of 3.8..
To load Dashicons for non logged in users:
Open directory {your-website-folder/wp-content/themes/}
Go into the folder of your active child theme ( if you don't have active child theme, open the folder of your active parent theme )
Find there functions.php file and add the provided code at the end of it (
make sure, there isn't ?> php closing tag at the end of file. if so, just remove it ):
function ww_load_dashicons(){
wp_enqueue_style('dashicons');
}
add_action('wp_enqueue_scripts', 'ww_load_dashicons');
Save changes. Dashicons will loads on your website for all users.
EDIT: there may be some plugin/code, which removed Dashicons from pages. Try to change your code with this one:
function ww_load_dashicons(){
wp_enqueue_style('dashicons');
}
add_action('wp_enqueue_scripts', 'ww_load_dashicons', 999);

Try this:
<span class="bx-next dashicons dashicons-arrow-right-alt2"></span>
'dashicons-arrow-right-alt2' is the class of the icon.
You can find them here: https://developer.wordpress.org/resource/dashicons/#arrow-up-alt
This has to go to your functions.php file:
function load_dashicons(){
wp_enqueue_style('dashicons');
}
add_action('wp_enqueue_scripts', 'load_dashicons');

For me the problem was simply that my browser blocker addons weren't allowing the source of dashicons.css

If you're using the plug-in "Asset CleanUp", you can navigate to "BULK CHANGES" and easily use "Remove site-wide rule" at the line, where the url for "dashicon" is listed.

Many of the icons on the official list were appearing blank for me when defined as a value of the menu-item property in the register_post_type function.
If you open wp-includes/css/dashicons.css you will see a complete list of icons available, many of which have different names, for example dashicons-quote is actually dashicons-editor-quote.
Using these values solved the problem for me. I also found this cheat sheet to be helpful if you don't want to go digging through your source files.

Solved for me— For some reason, dashicons was only not rendering when I wasn't accessing the https:// version of the site.

Related

Apply CSS file from activated WordPress Plugin

I am new to wordpress and want to know best way to add css from installed and activated plugin.
I have one activated plugin called "social-media" and in that plugin i have created one css file called "social-login-style.css"
I want to include this css file and apply style to my content. How should I add css file in any page so that I can see the effects.
In Short, I want to add social-login-style.css on wp-login.php file.
Whether it is theme or plugin, css or js, any custom addition, wp_enqueue_scripts is the only acton you need for all.
https://codex.wordpress.org/Plugin_API/Action_Reference/wp_enqueue_scripts
function additional_custom_styles() {
/* Enqueue The Styles */
wp_enqueue_style( 'custom-login-style', plugins_url( 'social-login-style.css', __FILE__ ) );
}
add_action( 'wp_enqueue_scripts', 'additional_custom_styles' );
If you it to be added only on login screen then use the following condition,
if ( $GLOBALS['pagenow'] === 'wp-login.php' ) {
// We're on the login page!
}
Hope this one help :)
UPDATE
Please check login_enqueue_scripts. it is designed to add custom scripts into login page only. Works well without any login condition.
https://codex.wordpress.org/Plugin_API/Action_Reference/login_enqueue_scripts
Without saying what you want to achieve is impossible, it certainly is against how WordPress is designed to work. Plugins are supposed to be modules that add to or modify how WordPress works. The folder of a plugin should only hold files pertaining to what the plugin does and, if it's a public plugin, its contents are controlled by a versioning (SVN) system.
In short, adding a file to an existing plugin will not have any effect, regardless of whether the plugin is active or not. And you should not add files to plugins you haven't developed yourself.
To load a CSS file on the login page, one should add an action hook to login_enqueue_scripts, as instructed in Customizing Login Form page of the codex. The stylesheet itself should be placed in either a custom plugin (you could create for your use-case) or inside the current theme folder.

Admin bar appears empty in WordPress

Admin bar appears after adding code to the functions.php
add_filter( 'show_admin_bar', '__return_true' );
but empty except for the WP logo and the search on the right.
I installed latest version of twentyTwelve, it didn't appear,after adding the same code to the theme's functions.php it appears with the same problem.
So I don't think it has to do with the theme.. So I deactivated all plugins, And I still have the same problem.
Note: There is no problem with the admin bar in the Dashboard. Also I checked the HTML structure, it's not hidden by CSS.
<?php wp_footer(); ?> + <?php wp_header(); ?> are defined in the themes header and footer.
If the toolbar is forced to load (via show_admin_bar) but a user is not logged in it has nothing to show the user. When this happens it looks exactly like your screen shot with just the WP and search icons present. The toolbar will load anytime a user is logged in though so there is no reason to force it to load unless you intend to modify its behavior to include actions for anonymous users.
I was able to recreate this easily in a clean install but only if there was no user logged in. If this is happening to you when a user is logged in then I suggest a fresh install of WP in a subdirectory, or locally, then enabling your theme and plugins one by one until it breaks so you know which component is causing the problem.

Wordpress: Simple solution to have mobile devices load a different homepage

I have done quite a bit of googling and have not found a simple solution for a method or a plugin to simply load a different static homepage for mobile devices. Is there a way to do this or a plugin that will do this (without revamping the whole site for mobile devices, as the mobile site style is good, but the specific static homepage is the only thing that I need changed). Wordpress CMS is the platform.
Thanks in advance!
Update:
So I installed the plugin suggested below, copied over an exact copy of the theme I am using but named it with 'mobile' in front just for reference, other than that everything is exactly the same. I read via google that I could add the following code into the functions.php theme file but it just shows up blank when I add the specific code. Code:
//Set Homepage
$mobilehome = get_page_by_title( 'mobilehome' );
update_option( 'page_on_front', $mobilehome->ID );
update_option( 'show_on_front', 'page' );
// Set the blog page
$blog = get_page_by_title( 'Blog' );
update_option( 'page_for_posts', $blog->ID );
Update 2, solved.
I found a simple solution. I created a new theme file 'page-home.php' and changed the css class '#primary' to '#primary-home', then went into the style.css file and added all '#primary-home' css attributes to match '#primary', except on the mobile CSS area of the stylesheet, I added "display:none;" to #primary-home. So now it just doesn't display the homepage on mobile devices, all other pages work (whole point in making the new template page and CSS attribute). I know this fix is probably the simple easy fix but it worked for me!
I found a simple solution. I created a new theme file 'page-home.php' and changed the css class '#primary' to '#primary-home', then went into the style.css file and added all '#primary-home' css attributes to match '#primary', except on the mobile CSS area of the stylesheet, I added "display:none;" to #primary-home. So now it just doesn't display the homepage on mobile devices, all other pages work (whole point in making the new template page and CSS attribute). I know this fix is probably the simple easy fix but it worked for me!
I think that this is as simple as it could get:
Try this plugin - UserAgent Theme Switcher
It will use the user-agent to detect which browser you are on, in this case it could be something like mobile safari or android, etc... then serve the theme based on that.
This could be a hit or miss because you might want or not to change the theme. A more advanced way to do this would be to use a jQuery plugin that checks for the user agent and lets you "do stuff" after you detect it, in this case it could serve as another page or change some CSS.
It's easy and no need to code everything. Install "Redirection" plugin from wordpress repository.
Go to the settings page.
Enter the "Source URL" with your default desktop's homepage
On the "Match" option, select "URL and user agent" & on the "Action" option select "Redirect to URL". Click "Add Redirection".
New configuration option will be appeared. Give any title you want. The "Source URL" must be blank (means that is your base homepage). On the "User Agent" option, choose whether iPhone or Android. On the "Matched" option, set the redirection you want for the mobile homepage.
Done!
You surely can differentiate the homepage on desktop and mobile device based on the redirection you have set before with that plugin. However, you cannot have same url name (ex: www.abcde.com for desktop & www.abcde.com/mobilehomepage for mobile device).

admin template selection is missing on page creation in wordpress 3.2.x

I am using WordPress 3.2.1 ,
Page template selection drop down is missing on Pages (Add,Edit)
wp-admin > Pages >Add New > Page Attributes
I Edit the Template Page Default page as below code
/*
Template Name: New Template
*/
But still the template drop down no visible , my older version of WordPress it display by default.
Following is the screen shot for more idea
I solved this problem solved by adding the typical following code:
/*
Template Name: Custom
*/
Don't add any spaces after Name:
It'll work if you use template name: as well.
It might help someone: check if your index.php file is in place.
If it's not there, wordpress treats the template as corrupt and it doesn't display the template selection.
This should be simple to troubleshoot. The requirements for the page template to work are straight forward:
The template needs the page title in the top of the file like you've shown (the title needs to be wrapped in a PHP tag, you probably just didn't add it with your example bu I want to make sure you havne't overlooked it):
<?php
/*
Template Name: Custom
*/
?>
The second requirement is that the file is in the root of the theme folder.
With those two requirements in place, it should work. If it isn't working you nave a few possible issues. I list a few off the top of my head:
You might need to re-install WordPress in-case a file was corrupted
during your last update.
It's possible someone has altered the WP-Admin layout using users
roles.
That's all I can thing of at the moment, let me know how it turns out.
I had the same issue. It actually turned out to be a missing style.css file within the template directory in my case.
This happens because the get_post_templates() in class-wp-theme.php first checks for errors. If it finds any then it returns an empty array (no templates are displayed).
A side effect of this is that saving a page would clear the existing template and use the page.php instead.
So in short if the errors() method of your theme returns any errors then no templates dropdown.
hope that helps someone.
Same issued, I found out that in appearance panel in your WordPress dashboard the stylesheet is missing. You shouldn't rename the style.css in your theme folder.
Not sure if this will help anyone, but we solved the problem by disabling our theme and re-enabling it again. We had some other theme folders in the theme directory that we weren't using so we deleted those out as well. good luck, it's a really random problem to solve!
yeah!template dropdown not showing because you have no template So how to solve this::---
1 create template folder in theme
2 create a template in this folder
like:-
<?php /* Template Name: Home */ echo "template"; ?>
and check-in page dropdown will be there.

why is the <?php wp_head ?> tag creating a top margin at the top of my theme header

Hey people, I've been coming here for a while but just decided to join.
I'm new to php and I'm trying to make a website with WordPress as the CMS.
Anyway, I'm basically making my own theme because I don't want my website to look like a blog, and it's going pretty smoothly so far but theres this huge top margin gap in the browser even when I set margins to 0px.
I tried trial and error and found out that it's being caused by: <?php wp_head(); ?>
It's two different things.
1. wp_head() function
wp_head() is a template tag to print whatever plugin / theme specific function used by wordpress action. Read codex for more detail about it.
2. The admin bar
The top margin, is generated by wordpress's admin bar.
To fix this for logged in users you can do a couple of things:
Disable admin bar from the admin:
Go to admin panel
Users >> User Profile
Uncheck 'when viewing
site' on 'Show Admin Bar'
Remove the admin bar from your theme entirely:
Open your functions.php
Add this to it:
function my_function_admin_bar(){ return false; }
add_filter( 'show_admin_bar' , 'my_function_admin_bar');
Remove only the code which creates the css:
Open your functions.php
Add this to it:
function my_filter_head() { remove_action('wp_head', '_admin_bar_bump_cb'); }
add_action('get_header', 'my_filter_head');
Note: Extensive updates are from #hitautodestruct
you neeed to call wp_footer() in your footer
just insert this line <?php wp_footer();?> into your footer.php file
If you have updated your wordpress install to the latest version.. there seems to be some bug with the admin bar...
were it would produce an inline stylesheet appended to the top of your pages.. causing the margin-top:28px
see here
1 recomendation is to put a new function into your functions.php file located in your theme folder.. this will completly remove the bar, so no users of your theme will have any of the same issues!
function my_function_admin_bar(){
return false;
}
add_filter( 'show_admin_bar' , 'my_function_admin_bar');
Not sure if this will help.. but worth a shot.. also turning off the admin bar while viewing the front end of the site under your profile page..

Resources