ChatGPT Functions: Observations, Tips, and Tricks

Category Image 062

Recently introduced ChatGPT functions represent a huge leap forward that lets ChatGPT use your local files, data, and system services. So, if you supply proper functions to ChatGPT, you can ask it something like “Email Kate Bell with birthday greetings” and see a new email message pop up with correct email address, correct subject and generated email text with birthday best wishes. 

Pretty cool, right?  

Chris’ Corner: More Like CSBest

Typography Definitions Cover

We gotta talk about CSS! That’s my favorite thing! It’s always on the table for a good Chris’ Corner edition, but sometimes focusing on it entirely is best.

Klint Finley called it “The modern web’s underrated powerhouse” for GitHub’s publication The ReadME Project back in February, and I’m inclined to agree. Although the days of CSS being considered underrated are waning. I get the sense that plenty of people find it complicated or generally just don’t like it, but those same people still respect its power. There is also one big undeniable fact: every website uses it. All of ’em. And it controls nearly every Aspect of how a website looks, which, ya know, if you care at all about how successfully your website does what it sets out to do, matters a whole heck of a lot.

Anyway, rather than listen to me prattle on about how good CSS is, let’s look at some interesting ideas pulled off in CSS, new things coming to CSS, dealing with browser support, and future ideas.


It used to be that if you used CSS to set the width and height of an image and the Aspect ratio that those two numbers formed didn’t match the Aspect ratio of the image, it would squish the image awkwardly. Almost certainly not the effect you want. But now we’ve got the object-fit property in CSS, and specifically the cover and contain values, which prevent the squishing. With cover, the image might crop, so you’re sending more image data than you needed to, perhaps, but you’ll be achieving the design you’re after.

With that as a foundation, let me let Henry Desroches take over in Using Focal Points, Aspect Ratio & Object-Fit To Crop Images Correctly. In conjunction with object-fit there is object-position which allows you to set an XY coordinate from where the image scales.

Try clicking different positions on the source image and see how the sized images change which part of the image they show. This is just good to know. If you’re ultimately cropping images, you don’t have to settle for the defaults.


You’d think “position this element over by this other element” would be easy peasy for CSS, but you’d be wrong. There has been no mechanism for that up until now. The new thing is called anchor positioning, and Jhey Tompkins has the scoop in Tether elements to each other with CSS anchor positioning.

The big obvious use case to all this for me is basically: tooltips powered by footnotes. Essentially I want bits of UI (a phrase, link, or [?] button) that can be hovered or otherwise interacted with to reveal a bit more information. But that information is elsewhere in the DOM. Wherever I want in the DOM that makes sense for my project. Finally, I’ll be able to do that (once is supported across all browsers or if I use the polyfill).

I had a little play with this myself, thanks to Jhey’s guidance in this post.

I didn’t get into all the scrolling stuff you have to think about or the @try style positioning, but I do think all that is very cool. Edge detection stuff is another thing that we’d have to lean on JavaScript to do normally, but never love having to do so.


As good as CSS has been lately with new features working across browsers, it’s still a thing we have to think about. Fortunately, CSS saw this coming long ago and has @supports rules that can help us conditionally apply CSS in supporting (or not) situations.

Stephanie Eckles has the most up-to-date information on all this in Testing Feature Support for Modern CSS.

An example I can think of is the kick-ass :has() selector. As I write, :has() isn’t supported in Firefox yet. So if we wanted to know that in CSS before we use it, we could do:

@supports selector(:has(a)) {
  /* styles when :has() is supported */
}

It is useful to think about what your plan is for detection, though. Like does it matter if Firefox doesn’t support :has() for what you are trying to do? Are you prepared to do it some other way if it’s not? As an example, I was talking to Eric Meyer the other day, and somehow table row/column highlighting came up, and he made a demo with :has().

Now you’d have to decide: how important is that effect? As written, in Firefox, just the cell you hover over highlights, so you could decide that’s fine, and then you don’t need any feature detection at all; you just let it fail. Alternatively, you could decide to use a @supports query in CSS and highlight the entire row if :has() isn’t supported, which is a similar effect (if not quite as cool).

Another decision you could make is to do the test in JavaScript and use a JavaScript-powered fallback if necessary. Good news, Stephanie has a JavaScript testing tool just for this. It uses a number of different techniques to report if a feature is supported or not. Ultimately you could use it for our :has() test like:

<script type="module">
  import * as SupportsCSS from "https://cdn.skypack.dev/supports-css@0.1.5";
  const tests = ["has"];
  SupportsCSS.init({ tests });

  if (!SupportsCSSTests.results.has) {
    document.head.insertAdjacentHTML(
      "beforeend",
      "<style>tr:hover { background: rgba(255,0,0,0.33); }</style>"
    );
  }
</script>

Ya know, just while we’re talking about feature detection in CSS, a typography-specific feature tester crossed my desk the other day, font-tech and font-format:

@supports font-tech(palettes) {
  .palette {
    display: block;
  }
}

@supports font-format(woff2) {
  div {
    display: block;
  }
}

Just interesting to me; I’ve never seen those specific functions before.


Wait, wait, I gotta do one more about feature detection. There are some things that you cannot detect in CSS, and is kind of a pain in the butt to detect in JavaScript also. Ahmad Shadeed made this point in Do we need CSS flex-wrap detection? The point has been made again and again that we need certain state detections like a :stuck selector for position: sticky; elements, and it sounds likely we’ll get that. But “is wrapped or not” is another form of state, I’d say. Ahmad’s use case was like… if a line in a flexbox layout wraps, it’s saying: “there isn’t room for these on one line”. But where that is is totally arbitrary based on content and element size. But if we knew exactly when that break was, we could, for example, use that exact moment to break a line of navigation into a hamburger rather than guessing at some magic number size. Strong point, I think.


I have an unnatural affinity for the “yellow fade technique”. It’s this idea that works with the :target selector in CSS and on-page anchor links. Imagine a table of contents where you click a link, and it jumps the page down (or scrolls, I suppose if you use scroll-behavior: smooth). How do you know exactly where the page is trying to take you to and draw your attention toward? The element is probably at the top of the page, but it might not be if the page is too short. The yellow fade technique just makes it way more clear. When that jump happens, that element becomes the :target, and you apply a background-color animation to it (light yellow!) that draws attention to it. It’s just nice, I think. There are some classic examples on CodePen, naturally.

The idea can also be applied to an element being added to the DOM, drawing attention to the fact that it just appeared. That’s what Bramus Van Damme does in The Yellow Fade Technique with Modern CSS using @starting-style.

Erm… @starting-style, what’s that? It’s basically built for the yellow fade technique. 😍.

div {
  transition: background-color 0.5s;
  background-color: transparent;

  @starting-style {
    background-color: yellow;
  }
}

With that, you don’t need a once-running @keyframes which ends up being more verbose and harder to understand. This way the transition essentially runs once on <div>s being added to the DOM. So I guess it’s not as perfect for the table of contents use-case, but it’s still pretty cool. Now I’m thinking about other DOM-entrance animations, like list items that slide in, or modals that fade in.


Sometimes we get new CSS stuff, and it’s just great right on the surface. Oh, the oklch() color function? Neat, it can do vibrant P3 colors. Neat, it has perceptually uniform lightness. Neat, the gradient interpolation is arguably nicer for some color pairings.

But then, over time, it turns out it’s how the new CSS feature is combined and interacts with other features that makes that feature shine even more. Aww, that was sweet, wasn’t it? We’re all better with a little help from our friends.

That’s what I was thinking about reading Adam Argyle’s A color-contrast() strategy for complimentary translucent backgrounds. If you haven’t seen color-contrast() yet, it’s a function that will pick the most visually contrasting color from a list of colors against a given color. That given color is probably a --custom-property meaning it can change and thus you don’t know ahead of time what the most contrasting color is. That’s awesome! But Adam takes it a little bit further. He wants to kick up the contrast even more by putting a slightly transparent black or white color behind the text.

html {
  --bg: hsl(var(--hue) 50% 50%);
}
  
h1 {
  --text: color-contrast(var(--bg) vs black, white);
  color: var(--text);
  background: hsl(0 0% 0% / 40%);
}
  
@supports (background: hsl(from red h s l)) {
  h1 {
    background: oklch(from color-contrast(var(--text) vs black,white) l c h / 40%);
  }
}

So cool. So individually, color-contrast() is neat, OKLCH is neat, @supports is neat, and the relative color syntax is neat, but combined, they really shine.

How to Fix the WordPress “White Screen of Death” (WSoD)

Featured Imgs 21
WordPress white screen of death.The WordPress White Screen of Death (WSoD) is arguably one of the most infuriating errors on the platform. Getting no indication of what has happened means you have to put in the work to find a fix. The error is also one that can cause some panic and anxiety. While you have the error, your site will be out of commission. Because of this, you need to work quickly and methodically to put everything right again. Fortunately, that’s where this tutorial comes in.

How To Avoid AI Hallucinations With ChatGPT

Category Image 062

Tage wrote about how to prevent ChatGPT from hallucinating a couple of months ago. However, I wanted to dive deeply into one specific thing you can do to completely avoid AI hallucinations. Before I explain how to avoid hallucinations, I need to explain a little bit about what we do when we create a custom ChatGPT chatbot.

What we do is prompt engineering based on an SQL database with VSS capabilities. It could be argued that we jailbreak ChatGPT, but instead of allowing ChatGPT to go completely berserk, we significantly restrict its capabilities to only be able to answer questions related to the data found in our SQL database. To understand the process, it helps to create your custom chatbot, something you can do below. 

How to Display Any Number of Posts in a WordPress Loop

Category Image 052

Do you want to show multiple blog posts in a WordPress loop?

Using the loop, WordPress processes each of the posts to be displayed on the current page. It formats them according to how they match specified criteria within the loop tags.

In this article, we will show how to display any number of posts in a WordPress loop.

How to display any number of posts in a WordPress loop

What Is the WordPress Loop?

The loop is used by WordPress to display each of your posts. It is PHP code that’s used in a WordPress theme to show a list of posts on a web page. It is an important part of WordPress code and is at the core of most queries.

In a WordPress loop, there are different functions that run to display posts. However, developers can customize how each post is shown in the loop by changing the template tags.

For example, the base tags in a loop will show the title, date, and content of the post in a loop. You can add custom tags and display additional information like the category, excerpt, custom fields, author name, and more.

The WordPress loop also lets you control the number of blog posts that you show on each page. This can be helpful when designing an author’s template, as you can control the number of posts displayed in each loop.

That being said, let’s see how to add any number of posts to a WordPress loop.

Adding Any Number of Posts in a WordPress Loop

Normally, you can set the number of posts to be displayed in the loop from your WordPress admin panel.

Simply head to Settings » Reading from the WordPress dashboard. By default, WordPress will show 10 posts.

Reading settings WordPress

However, you can override that number by using a Super Loop, which will allow you to display any number of posts in that specific WordPress loop.

This will allow you to customize the display settings of your pages, including author profiles, sidebars, and more.

First, you will need to open a template file where you would like to place the posts and then simply add this loop:

<?php
// if everything is in place and ready, let's start the loop
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

	// to display 'n' number of posts, we need to execute the loop 'n' number of times
	// so we define a numerical variable called '$count' and set its value to zero
	// with each iteration of the loop, the value of '$count' will increase by one
	// after the value of '$count' reaches the specified number, the loop will stop
	// *USER: change the 'n' to the number of posts that you would like to display

	<?php static $count = 0;
	if ( $count == "n" ) {
		break;
	} else { ?>

		// for CSS styling and layout purposes, we wrap the post content in a div
		// we then display the entire post content via the 'the_content()' function
		// *USER: change to '<?php the_excerpt(); ?>' to display post excerpts instead

		<div class="post">
			<?php the_title(); ?>
			<?php the_content(); ?>
		</div>

		// here, we continue with the limiting of the number of displayed posts
		// each iteration of the loop increases the value of '$count' by one
		// the final two lines complete the loop and close the if statement

		<?php $count ++;
	} ?>
<?php endwhile; ?>
<?php endif; ?>

Note: You will need to replace the value of ‘n‘ in the if ( $count == "n" ) part of the code and choose any number.

An easy way to add this code to your WordPress website is by using the WPCode plugin. It is the best code snippet plugin for WordPress that helps you manage custom code.

By using WPCode, you don’t have manually edit theme template files and risk breaking something. The plugin will automatically insert the code for you.

First, you need to install and activate the free WPCode plugin. For more details, please see our guide on how to install a WordPress plugin.

Upon activation, you can head to Code Snippets » + Add Snippet from your WordPress dashboard. Next, you need to select the ‘Add Your Custom Code (New Snippet)’ option.

Add new snippet

After that, simply paste the custom code for the WordPress loop that we showed you above into the ‘Code Preview’ area.

You will also need to enter a name for your code and set the ‘Code Type’ to ‘PHP Snippet’.

Add custom loop code to WPCode

Next, you can scroll down to the ‘Insertion’ section and choose where you would like to run the code.

By default, WPCode will run it everywhere on your WordPress website. However, you can change the location to a specific page or use a shortcode to insert the code.

Edit insertion method for code

For this tutorial, we will use the default ‘Auto Insert’ method.

When you are done, don’t forget to click the toggle at the top to make the code ‘Active’ and then click the ‘Save’ button. WPCode will now deploy the code on your WordPress blog and display the specified number of posts in the WordPress loop.

We hope this article helped you learn how to display any number of posts in a WordPress loop. You may also want to see our guide on how to exclude sticky posts from the loop in WordPress and our expert picks for the must-have WordPress plugins for business websites.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Display Any Number of Posts in a WordPress Loop first appeared on WPBeginner.

The Power of Yelp: Why it Matters in Today’s Digital Landscape

Featured Imgs 11
The Power of Yelp: Why it Matters in Today's Digital Landscape

Yelp is a popular online platform that provides a platform for users to find and review local businesses. It allows individuals to search for various types of businesses, such as restaurants, hotels, shops, and service providers, and read reviews and ratings left by other users. The platform also enables users to contribute their own reviews and experiences, giving them a voice and helping others make informed decisions about where to go and what services to use.

Yelp matters for several reasons:

Customer Insight: Yelp offers valuable customer feedback and insights into businesses' quality of products and services. People trust user-generated reviews, making Yelp a reliable source for gauging a business's reputation and customer satisfaction.

Business Visibility: For businesses, having a presence on Yelp can significantly increase their online visibility. Positive reviews and high ratings can attract more potential customers and improve their chances of getting noticed in a crowded market.

Online Reputation Management: Yelp provides businesses with an opportunity to manage their online reputation. Responding to reviews, addressing concerns, and engaging with customers can demonstrate excellent customer service and build trust.

Local Marketing: Yelp is especially beneficial for local businesses as it helps them reach their target audience within their geographic area. By optimizing their Yelp profile and maintaining a positive reputation, local businesses can attract nearby customers.

Social Proof: Yelp's user-generated reviews and ratings act as social proof for businesses. Positive reviews serve as recommendations, influencing potential customers' decisions and increasing the likelihood of conversions.

Competitive Advantage: Businesses with a strong presence on Yelp and positive reviews can gain a competitive edge over their rivals. Customers are more likely to choose a business with a higher rating and more positive reviews.

Mobile and Local Searches: As mobile and local searches have become prevalent, Yelp has become even more crucial. Many people use Yelp on their mobile devices to find nearby businesses quickly.

How to Email Authors When Articles Are Published in WordPress

Featured Imgs 23

Do you want to email authors when their articles are published in WordPress?

If you run a multi-author blog, then notifying authors when their blog posts are published keeps them informed. Plus, it can also help increase engagement on your website since authors can quickly share their content and participate in discussions.

In this article, we will show you how to email authors when their articles are published in WordPress.

Email authors when their articles are published in WordPress

Why Email Authors When Their Articles Are Published in WordPress?

By notifying authors when their posts are published on your WordPress blog, you allow them to immediately promote their work on social media platforms and communicate with readers in the comments section.

Additionally, notifications keep authors updated about the publication statuses for different posts. This helps build trust among your team by showing that you value the writer’s contributions to your multi-author blog.

By alerting authors immediately upon post publication, you also give them the opportunity to view their content and correct any typos or errors before visitors have a chance to read it.

Having said that, let’s see how to easily email authors when their articles are published in WordPress. You can use the links below to jump to the method of your choice:

Method 1: Email Author When Their Article Is Published in WordPress Using a Plugin

If you prefer to use a plugin to notify your authors, then this method is for you.

First, you need to install and activate the PublishPress Planner plugin. For detailed instructions, you may want to see our beginner’s guide on how to install a WordPress plugin.

Note: You can also use the PublishPress Pro plan to unlock more features like Slack integration, send reminder notifications, and meta posts. This will help you improve the overall editorial workflow of your multi-author blog.

Upon activation, you need to visit the Planner » Settings page from the WordPress admin sidebar and switch to the ‘Notifications’ tab.

Once you are there, type in the admin email address that will be used to send emails to your authors next to the ‘Email from’ option.

After that, check the ‘Always notify the author of the content’ option to send emails to authors every time their posts are published on your website.

Check the always notify author option

If you also want to notify the users who edited the post, then you can check the ‘Always notify users who have edited the content’ option.

Once you are done, click the ‘Save Changes’ button to store your changes.

Now, when you publish an author’s post, they will receive an email notification that looks like this:

Preview of author email notification upon post publication

Method 2: Email Author When Their Article Is Published in WordPress Using Code

If you don’t want to use a plugin, then you can also automatically send emails to authors by adding code to your theme’s functions.php file.

However, the smallest error when adding code can break your website and make it inaccessible.

That is why we recommend always using WPCode. It is the best WordPress code snippets plugin on the market that makes it super safe and easy to add custom code to your website.

First, you need to install and activate the WPCode plugin. For details, you can see our step-by-step guide on how to install a WordPress plugin.

Note: You can also use WPCode’s free plan for this tutorial. However, upgrading to the pro version will give you access to more features like a code snippets library, conditional logic, CSS snippets, and more.

Upon activation, simply visit the Code Snippets » + Add Snippet page from the WordPress dashboard. Then, click the ‘Use Snippet’ button under the ‘Add Your Custom Code (New Snippet)’ option.

Add new snippet

This will take you to the ‘Create Custom Snippet’ page, where you can start by adding a title for the code snippet.

After that, select the ‘PHP Snippet’ option from the Code Type dropdown menu on the right.

Choose the PHP Snippet option for emailing authors upon post publication

Now copy and paste the following custom code into the ‘Code Preview’ box:

function notifyauthor($post_id) {
 
$post = get_post($post_id);
$author = get_userdata($post->post_author);
$subject = "Post Published: ".$post->post_title."";
 
$message = "
      Hi ".$author->display_name.",
       
      Your post, \"".$post->post_title."\" has just been published.
       
      View post: ".get_permalink( $post_id )."
       
      Thanks"
      ;
       
   wp_mail($author->user_email, $subject, $message);
}
add_action('publish_post', 'notifyauthor');

This code runs when a new post is published in WordPress. It sends an email notification to the author using the subject and message defined in the code. Feel free to change the subject and message fields to meet your needs.

Once you have done that, scroll down to the ‘Insertion’ section and choose the ‘Auto Insert’ mode. The code will be automatically executed on your website upon activation.

Choose an insertion method

Finally, scroll back to the top and toggle the ‘Inactive’ switch to ‘Active’.

After that, click the ‘Save Snippet’ button to store your settings.

Save the snippet for emailing authors upon post publication

Now, when you publish a post, the author will automatically receive an email notification.

It will look like this:

Preview for sending email notification to authors upon post publication

Bonus: Use WP Mail SMTP to Send Your Emails

When you send emails to your authors about their published posts, you are using the default WordPress email settings, which are not always reliable.

This means that your email may not reach the author or might even end up in their spam folder.

To fix this issue, you can use WP Mail SMTP, which is the best WordPress SMTP plugin on the market. It uses the SMTP (Simple Mail Transfer Protocol) method for mail transmission and eliminates your email delivery problems.

WP Mail SMTP website

You can easily connect WP Mail SMTP with popular email marketing services and make sure that your emails reach the user’s inbox immediately.

With WP Mail SMTP, you can easily avoid the spam folder, track your email logs, use backup connections and failure alerts, and use premade templates to send emails to your users.

For detailed instructions, you can see our beginner’s guide on how to properly configure your WordPress email settings.

We hope this article helped you learn how to email authors when their articles are published in WordPress. You may also want to see our tutorial on how to highlight author comments in WordPress and our expert picks for the best free author bio box plugins in WordPress.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Email Authors When Articles Are Published in WordPress first appeared on WPBeginner.

How to Retrieve WiFi Password on Windows

Featured Imgs 23

Remembering the WiFi password when on a guest network is never easy. Even worse is when it’s no longer posted and someone else is asking you for it. Luckily there’s a built in Windows command to recover the password of a given WiFi network.

The Shell Code

Open cmd and execute the following command:

netsh wlan show profile name="David Walsh's Network" key=clear

The result of the command, assuming the network is found, is a long text output with a variety of information about the network. To get the see the password for the network, look under the “Security settings” heading which will look like this:

Security settings
-----------------
    Authentication         : WPA2-Personal
    Cipher                 : CCMP
    Authentication         : WPA2-Personal
    Cipher                 : GCMP
    Security key           : Present
    Key Content            : **THE_PLAIN_TEXT_PASSWORD**

As with any complicated command line format, it’s best to create an alias so that you don’t need to remember the full string!

The post How to Retrieve WiFi Password on Windows appeared first on David Walsh Blog.