How to preload images through Code Snippets wp_head for specific pages?

Circumstances: Website Structure My Wordpress website is used as presentation and portfolio for my graphic design services. Visual impact is important for me, so most of my pages contain big background hero image as first impresions and/or entrance animations. Languages Is relevant to share that all of the pages have two versions: one for english and one for spanish. It matters because I'm trying to preload specific images for both versions of a page (example: Contact page in english and …
Category: Web

Proper after_setup_theme and wp_head cleanup

Im trying to clean up code in my theme a little bit, remove some of the code that is not used and basically do things the right way, to decrease load time etc. Currently I have this code: add_action('after_setup_theme', 'rm_theme_setup'); // start theme setup function rm_theme_setup() { add_action('init', 'rm_head_cleanup'); // * 1) calling the function below add_action('wp_head', 'rm_remove_recent_comments_style', 1); add_filter('gallery_style', 'rm_remove_gallery_style'); rm_add_theme_support(); // * 2) calling the function to add theme support } 1) This is the wp_head cleanup part: …
Category: Web

custom COOKIE on custom page

i have problem with create function for set cookie dynamically. when i try in custom page i have of course header is set and i tried something like this: in custompage.php: myfunction($cookiename,$cookievalue); in function.php add_action("init","myfunction",10,2); function myfunction($name,$value) { setcookie($name,$value,time()+3600); } add_action("wp_head","mySEOfunction",10,2); function mySEOfunction($name,$value) { echo "some meta tags...".$name... } i have Missing argument 2 in function.php i tried also this for SEO meta tags created dynamically but i have same problem... any help?
Category: Web

Front End Page Not Loading Header Footer

I followed the directions at http://blog.frontendfactory.com/how-to-create-front-end-page-from-your-wordpress-plugin/ and it works but the header and footer do not load. Here is my page: http://pocket.consulting/bg-core/ UPDATE: I stand corrected... It appears the wp_head(); and wp_footer(); do load as it is altering the color, font, etc. Is there something else I have to call to get the entire look/feel?
Category: Web

CSS from textarea in options page to frontend what to do

I have a textarea for small css enhancements on the plugins page i output them directly to the head. My Question is how to sanitize the CSS i have validation function registered for the options with register_setting. On the setting page right now $output['css'] = (string) $input['css']; is all what i am doing. Should i escape it somehow? What does word-press with it? Does it some escaping by itself for database? I could there some evil injection take place here. …
Category: Web

How to output wp_enqueue_style() in HTML head instead of footer

I added some actions to wp_enqueue_scripts to load my custom css and js files in the header section by using wp_head(); right before the closing </head> tag. function mytheme_scripts(){ // Load our main stylesheet wp_enqueue_style( 'mytheme-css', get_template_directory_uri() . '/css/styles.min.css', false); // Load concatenated vendors JavaScript file wp_enqueue_script( 'vendors-js', get_template_directory_uri() . '/js/vendors.min.js'); // Load our main JavaScript file wp_enqueue_script( 'mytheme-js', get_template_directory_uri() . '/js/app.min.js', array( 'vendors-js' )); } add_action( 'wp_enqueue_scripts', 'mytheme_scripts', false); While both *.js files are loaded in the HTML <head> …
Category: Web

Adding Plugin Assets to Header

I am creating a WordPress Plugin. I have already added some pages. But I want to add custom CSS to that pages in the <head>. I am trying: add_action( 'wp_head', 'DisHeaderAssets'); But nothing shows up in the header. I have placed this in the plugin's functions.php file which is called immediately when plugin is loaded. functions.php add_action( 'wp_head', 'DisHeaderAssets') function DisHeaderAssets() { ?> <link rel="icon" type="image/png" href="images/icons/favicon.ico"/> <!--===============================================================================================--> <link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css"> <!--===============================================================================================--> <link rel="stylesheet" type="text/css" href="fonts/font-awesome-4.7.0/css/font-awesome.min.css"> <!--===============================================================================================--> <link rel="stylesheet" …
Category: Web

Scanning for custom embed and prefetching

I have an embed which is essentially a script and a div (so not an oembed) which can easily be added via the html block. I'd like to be able to slip a prefetch link conditionally into the head when someone's used the embed, but not have it in every page by default. I have a solution: function prefix_filter_embeds( $content ) { if strpos( $content, "url-we're-looking-for" ) !== false ) { add_action( 'wp_head', 'prefix_url_actions', 0 ); } return $content; } …
Category: Web

Putting content into header.php without using wp_head

I am building a plugin. I have to output certain stuff in the header.php file of the theme depending on if/else I will write. However I am not at that point yet. I just learned in order to push the function into header.php I have to use wp_head. Unfortuatenly when I do this I get a lot of extra stuff processed by WordPress jammed into the wp_head function. <meta name='robots' content='noindex,follow' /> <script type="text/javascript"> window._wpemojiSettings = {"baseUrl":"https:\/\/s.w.org\/images\/core\/emoji\/72x72\/","ext":".png","source":{"concatemoji":"http:\/\/zachis.it\/client\/wgp-master\/wp-includes\/js\/wp-emoji-release.min.js?ver=4.4.2"}}; !function(a,b,c){function d(a){var c,d=b.createElement("canvas"),e=d.getContext&&d.getContext("2d"),f=String.fromCharCode;return …
Category: Web

How to replace the existing metatag using the backend to insure a thumbnail image gets fetched when we share on social media?

How to replace the existing metatag using the backend to insure a thumbnail image gets fetched when we share on social media? function theme_a_header_metadata() { global $post; $image = \wpplugin\blogwidget\getBlogImage($post); ?> <meta property="og:image" content="<?= getLocalImage($image, '1344x') ?>" /> <?php } add_action( 'wp_head', 'theme_a_header_metadata' ); So I have this function, but the issue is that there's already a meta property with the property value of "og:image", so how do I replace the meta tag? I need to use the backend, and …
Category: Web

is there a way to preload specific images for desktop users only? (excluding mobile users)

My website has a few .PNG images animated at the very start of my Contact page. Those images are a bit heavy (because they have transparent background), so the animation starts with some of them loading during the animation, looking pretty bad. So, to fix it, I must add this line <link rel="preload" as="image" href="url-of-the-image.png"/> to the <head>. To achieve it, I'm using Snippets plugin. If I'm not mistaken, the snippet should like this: add_action( 'wp_head', function () { ?> …
Category: Web

Remove CSS & JS from <?php wp_head(); ?>

I've been with this problem for a couple of days and the truth is that I can not find a solution. I have added code manually in wp-header.php and now I need to delete these lines that it generates automatically The lines I want to eliminate are: &lt;link rel="stylesheet" id="create-css" href="http://www.myweb.com/wp-content/themes/movil/create.css?ver=4.9.8" type="text/css" media="all" data-inprogress=""&gt; &lt;script type="text/javascript" src="http://www.myweb.com/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://www.myweb.com/wp-includes/js/jquery/jquery.js?ver=1.12.4"&gt;&lt;/script&gt; thaks!!
Category: Web

Remove meta description on certain pages

Wordpress renders a meta description tag with the content of the blog post as the value for the description. I already generated in the header.php what I want the description to be, no matter what. However, the old one is still in there. I checked single-post.php and header.php and there is nothing rendering the meta description. So it HAS to be the wp_head() function. Is there anyway I can put something in my functions.php or something to ensure that on …
Category: Web

How do I add a logo to my website?

I would like to know how to do add a logo to my website, before the site title. &lt;html &lt;?php language_attributes(); ?&gt;&gt; &lt;head&gt; &lt;meta charset="&lt;?php bloginfo( 'charset' ); ?&gt;" /&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt; &lt;link rel="profile" href="http://gmpg.org/xfn/11" /&gt; &lt;link rel="pingback" href="&lt;?php bloginfo( 'pingback_url' ); ?&gt;" /&gt; &lt;?php /* Embeds HTML5shiv to support HTML5 elements in older IE versions plus CSS Backgrounds */ ?&gt; &lt;!--[if lt IE 9]&gt; &lt;script src="&lt;?php echo get_template_directory_uri(); ?&gt;/js/html5shiv.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;![endif]--&gt; &lt;?php wp_head(); ?&gt; &lt;/head&gt; &lt;body &lt;?php …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.