Semantic Search With Weaviate Vector Database

Featured Imgs 23

In a previous blog, the influence of the document format and the way it is embedded in combination with semantic search was discussed. LangChain4j was used to accomplish this. The way the document was embedded has a major influence on the results. This was one of the main conclusions. However, a perfect result was not achieved. 

In this post, you will take a look at Weaviate, a vector database that has a Java client library available. You will investigate whether better results can be achieved.

How to Add Custom Meta Boxes in WordPress Posts and Post Types

Featured Imgs 13

Do you want to learn how to create custom meta boxes for your WordPress posts, pages, and custom post types?

WordPress adds metadata to your content automatically, such as the publication date, categories, and tags. However, you may also want to add your own custom meta data.

In this article, we will show you how to easily add unique information to your content, by creating a custom meta data box in WordPress.

How to add custom meta boxes in WordPress posts and post types

What is a Custom Meta Box in WordPress?

When you create posts and pages, or custom post types in WordPress, that content usually has its own metadata. This metadata is information related to the content like date and time, the author name, title, and more.

You can also add your own metadata using the default custom fields box.

Adding custom meta boxes in WordPress posts

Pro Tip: Can’t see the Custom Fields box in the post editor? Then see our guide on how to fix custom fields not showing in WordPress.

The Custom Fields box is a good solution if you just want to add custom metadata to a few posts. However, if you plan to add lots of unique information to your content, then it makes sense to create a custom metadata box.

In fact, many of the popular WordPress plugins add custom meta boxes to the Edit screen for posts and pages. In the following image, you can see how easy it is to add SEO information to your post, using a custom meta box provided by AIOSEO.

The All in One SEO (AIOSEO) WordPress plugin

With that being said, let’s see how you can easily add custom meta boxes in WordPress posts and post types.

How to Add Custom Meta Boxes in WordPress Posts and Post Types

The easiest way to add custom meta boxes to WordPress is by using Advanced Custom Fields. This plugin allows you to attach all kinds of extra information to your posts and pages, and then show that data to visitors using a shortcode.

The first thing you need to do is install and activate the Advanced Custom Fields plugin. For more details, see our step-by-step guide on how to install a WordPress plugin.

Create a Custom Meta Box

Upon activation, go to ACF » Field Groups and then click on the ‘Add New’ button.

Adding a custom field to your WordPress website

Here, you can create the custom fields that will appear in the metadata box.

To start, you’ll need to type a title into the field that shows ‘Field Group Title’ by default. This will appear in the WordPress content editor, and it will be used as the title of your meta box.

With that being said, you should use something descriptive, especially if you manage a multi-author WordPress blog or share the dashboard with other people.

How to easily add custom meta data to your website or blog

With that done, you’re ready to add the first field to your meta box.

Add Custom Fields to the Meta Box

To start, open the ‘Field Type’ dropdown and choose the type of field you want to add, such as Text, Date Picker, Checkbox, or any other field type.

Adding custom fields to the WordPress content editor

After that, type in a label for the field.

Advanced Custom Fields will show this label before the field, so it will help users understand what information they need to enter.

The Advanced Custom Fields WordPress plugin

Advanced Custom Fields will generate the ‘Field Name’ automatically, so you can leave this field empty.

With that done, you may want to type in a ‘Default Value.’ This will be added to the page, post, or custom post type automatically if the user doesn’t add their own information.

Adding default values to custom WordPress fields

You may see more options depending on the kind of field you’re creating. For example, if you selected ‘Image’ from the ‘File Type’ dropdown, then you can choose the image format.

Most of these options are self-explanatory so you can follow the onscreen instructions to configure the custom field.

When you’re happy with how the field is set up, click on ‘Close Field’ to collapse the section.

Adding custom data to a website or blog

You can now add more fields to the custom meta box by clicking on the ‘Add Field’ button.

Then, simply configure the field by following the exact same process described above.

Saving a custom field group

Add a Custom Meta Box to the WordPress Content Editor

When you’re happy with how the custom meta box is set up, you’ll need to define where and when the meta box will appear.

Scroll to the ‘Settings’ section and then click on the ‘Location Rules’ tab.

Controlling where custom content appears in the WordPress content editor

Advanced Custom Fields can add the box to all kinds of content. For example, you can show the meta box on specific post types, categories, taxonomies, navigation menus, and more.

Simply use the dropdown menus to choose where the meta box will appear in your WordPress dashboard. For example, if you accept guest posts then you may want to add the box to all posts in the ‘Guest Posts’ category.

Creating content rules using a WordPress plugin

After that, click on the ‘Presentation’ tab.

Here, you can choose the meta box style, where it appears on your WordPress blog, and where the label and instructions will appear.

ACF's presentation settings in the WordPress dashboard

If you plan to add multiple boxes in the same location, then you can change the order they appear in by typing into the ‘Order No’ field.

For example, showing the most important meta boxes towards the top of the screen may improve your editorial workflow.

If you’re unsure, then you can leave this field set to 0.

Reorganizing fields in the WordPress content editor

On this screen, you’ll also see a list of all the fields that WordPress usually shows on the post edit screen.

If you want to hide a field, then simply check its box. For example, if you’re using custom fields to create an author info box, then you may want to hide the default ‘Author’ field.

Hiding fields in the WordPress post editor

When you’re happy with the changes you’ve made, click on ‘Save Changes’ to make the field group live.

You’ve now successfully created a custom meta box for your WordPress post, page, or custom post type. Depending on your settings, you can now visit the post editor to see the custom meta box in action.

An example of a custom meta data box, created using a free WordPress plugin

Displaying Your Custom Meta Box Data in WordPress Theme

You’ve now successfully added a custom meta box to the WordPress dashboard. Any information users type into the meta box will be stored in the WordPress database when they save or publish the post. However, this information won’t appear on your website by default.

With that in mind, let’s make sure the custom metadata appears in your WordPress theme, so visitors can see it.

You can do this using shortcode or by editing your WordPress theme files.

How to Display Custom Metadata using Shortcode

Adding a shortcode in WordPress is the easiest method, and allows you to control exactly where the information appears on your website. For example, if you’ve created a ‘Star Rating’ field, then you can show this information after the post title, inside the content, in the footer, or anywhere else simply by adding a shortcode.

However, you will need to add a shortcode to every page, post, or custom post type manually. This can take a lot of time and effort, especially if you have a lot of content.

To get a field’s shortcode, go to ACF » Field Groups. Then, hover over the field group that you want to display and click on the ‘Edit’ link when it appears.

Editing a meta data field group

You’ll now see all the fields that make up this group.

For each field you want to display, make a note of the value in the ‘Name’ field.

How to show custom data in your WordPress theme using shortcode

With that done, go to the page, post, or custom post type where you want to show the custom metadata.

You can now click on the ‘+’ icon and type in ‘Shortcode.’

Adding shortcode to a WordPress page or post

When the right block appears, click to add it to your layout.

You can now add the following shortcode to the block, making sure to replace "article_byline" with the name of the field you want to show.

Adding custom meta data to a WordPress theme

You can now repeat these steps to add multiple custom fields to the post.

When you’re happy with the changes you’ve made, either click on the ‘Publish’ or ‘Update’ button. Now, simply visit your WordPress website to see the custom metadata in action.

An example of custom meta data, displayed using a shortcode

How to Display Custom Metadata by Editing Your WordPress Theme

If you want to show custom metadata in the same location on every page, post, or custom post type, then you can add code to your WordPress theme files.

This can save you time in the long-term, but it isn’t the most beginner-friendly method. You’ll also lose all the custom code the next time you update your WordPress theme, which is why we recommend creating a child theme. You can then add your custom code to the child.

If you haven’t edited your theme files before, then take a look at our beginner’s guide on how to copy and paste code in WordPress.

You’ll need to edit the file where you want to show the custom metadata. This will vary depending on your theme, but you’ll usually need to edit your site’s single.php, content.php, or page.php file.

Once you have the right file, you’ll need to add the code inside the WordPress loop. To find this loop, simply search for code that looks something like this:

	<?php while ( have_posts() ) : the_post(); ?>

You can then paste your code after this line and before the line that ends the loop:

	<?php endwhile; // end of the loop. ?>

As an example, your custom field code should look something like this:

	<h2 class="article-byline"><?php the_field('article_byline'); ?></h2>

Notice how we wrapped the code in a h2 heading with a CSS class. This allows us to format and style the custom field later by adding custom CSS to our theme.

Here’s another example:

<blockquote class="article-pullquote">
 
<?php the_field('article_pullquote'); ?>
 
</blockquote> 

When adding code to your theme, don’t forget to replace the field names.

With that done, you can visit any post where you’ve already entered data into the custom fields. You will now see your unique metadata in action.

How to add custom fields to a WordPress theme

We hope this article helped you learn how to add custom meta boxes in WordPress posts and post types. You may also want to see our guide on how to create automated workflows in WordPress, or see our expert pick of the best SEO plugins and tools that you should use.

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 Add Custom Meta Boxes in WordPress Posts and Post Types first appeared on WPBeginner.

Critical Infrastructure Protection in the Age of Cyber Threats

Featured Imgs 23

Critical Infrastructure Protection is the need to safeguard a nation/region's important infrastructures, such as food, agriculture, or transportation. Critical infrastructures include transportation systems, power grids, and communication systems. Critical infrastructure protection is important to communities because any damage to these infrastructures is dangerous to global economies and the world.

 A cyber or cybersecurity threat is a harmful act that seeks to steal data, damage data, or disrupt digital life. Cyber threat is also the possibility of a successful cyber attack that aims to gain prohibited access to damage, disrupt, or steal an information technology asset, computer network, intellectual property, or any other form of sensitive data. Critical infrastructure protection is important to communities because any damage to these infrastructures is dangerous to global economies and the world.

Mastering Data Preparation for Effective Dashboards

Featured Imgs 23

A Concise Guide To Mastering Data Preparation for Effective Dashboards

In the era of data-driven decision-making, Dashboards have become indispensable everyday tools for visualizing data insights and trends. However, the effectiveness of these dashboards is heavily dependent on the structure and the quality of the underlying data. This article dives into the critical processes of data cleaning, data blending, and data modeling and provides a roadmap for data preparation that powers insightful, actionable, and effective dashboards.

Foundation: The Three Pillars of Data Preparation

Before a dataset can be transformed into a compelling dashboard, it must undergo a meticulous data preparation process. This process ensures that data is accurate, consistent, and in a format that can be easily and effectively analyzed and consumed by the data visualization tools. 

Unveiling the Power of Virtual Private Networks (VPNs)

Featured Imgs 23

Concerns about internet privacy and security are more common than ever in the quickly changing digital environment. As individuals and organizations participate in a variety of online activities, the necessity to protect sensitive information has resulted in the widespread use of Virtual Private Networks (VPNs). In this complete overview, we will look at VPN capabilities, benefits, potential pitfalls, and how they help to provide a safe and private internet experience.

While the possible disadvantages of VPN use are essential to consider, it is critical to recognize that many of these issues may be efficiently addressed by educated decision-making and planned deployment. Understanding the unique dangers and adopting proper solutions allows users to reap the benefits of VPNs while mitigating the effect of negative. As the digital world changes, VPN technology is expected to adapt and develop to handle these difficulties, resulting in an even more secure and smooth online experience.

Chris’ Corner: Some AdviCSS

Category Image 052

Get it?! Like “advice”, but for CSS.

When should you nest CSS?

Scott Vandehey says:

There’s a simple answer and a slightly more complicated answer. The simple answer is “avoid nesting.” The more practical, but also more complex answer is “nest pseudo-selectors, parent modifiers, media queries, and selectors that don’t work without nesting.”

The big idea behind avoiding nesting (which is a native CSS feature now, if you hadn’t heard) is that it can lead to specificity increases that just aren’t necessary. Like:

.card {
  .content {
    .byline {

    }
  }
}

That .byline selector probably doesn’t gain anything by being nested like that. Break it out of there and it’ll be more re-usable and easier to override if you need to.

But this:

.card {
  @container (width > 60ch) {

  }
}

Is probably good! It just saves you from having to re-write the .card selector again. Scott gets more in-depth though with more examples and I largely agree.

How do you adjust an existing color light and darker?

I’m a biiiig fan of the relative color syntax, which is great at this job, but before I go on a tangent about that, it’s not well supported yet so let’s not. It’s on the Interop 2024 list though!

Better supported is color-mix(), and Cory LaViska has the story on using it for this job:

Using color-mix(), we can adjust the tint/shade based on the background color, meaning we don’t need to manually select lighter/darker colors for those states. And because we’re using OKLCH, the variations will be perceptually uniform, unlike HSL.

By mixing white and black into colors, and doing it in the OKLCH color space, we can essentially tint and shade the colors and know that we’re doing it evenly across any color we have. This is as opposed to the days when a lot of us tried to use darken() and such in Sass only to find extremely different results across colors.

How are the final values of Custom Properties calculated?

Stephanie Eckles:

Custom properties – aka “CSS variables” – seem fairly straightforward. However, there are some behaviors to be aware of regarding how the browser computes the final values. A misunderstanding of this process may lead to an unexpected or missing value and difficulty troubleshooting and resolving the issue.

Custom Properties follow the cascade and are computed at runtime, for one thing, which is the whole reason that they cannot be preprocessed ahead of time. But it’s more complex than that. What if the value is valid for a custom property (most anything is), but not valid for the way you are trying to use it?

This is a real head scratcher:

html { color: red; }

p { color: blue; }

.card { --color: #notacolor; }

.card p { color: var(--color); }

Turns out .card p will actually be red (I would have guessed blue), but Stephanie explains:

The .card p will be the inherited color value of red as provided by the body. It is unable to use the cascaded value of blue due to the browser discarding that as a possible value candidate at “parse time” when it is only evaluating syntax.

How do you accommodate people who struggle with transparent interfaces?

Adam Argyle explains it can be like this, using this media query you may or may not have heard of:

.example {
  --opacity: .5;

  background: hsl(200 100% 50% / var(--opacity));

  @media (prefers-reduced-transparency: reduce) {
    --opacity: .95;
  }
}

Adam had lots of practical examples in the post, and does consider that word reduced, and how it doesn’t mean absolutely none ever.

What units should you use for spacing properties?

Me, I just use rem usually as that’s what I use for nearly everything else. But Ashlee M Boyer argues that while stuff like text makes good sense to use relative units, spacing need not scale at that same rate:

When a user is customizing their viewing experience, they thing that’s most important to them and their task at hand is the content. Spacing isn’t often vital for a user to perform their task, so it doesn’t need to grow or scale at the same rate as the content itself.

When spacing between content grows, it eats up vital real estate and becomes harder to manage.

Ashlee proves it with a before video and an after video, after being moving relative units to absolute units for spacing.

How do you make every Sass file automatically include common imports?

This one hits home for me, as someone with a codebase with easily hundreds of Sass files that all start with something like @import "@codepen/variables"; Wouldn’t it be cool if Sass could just assume we wanted to do that for every file?

Austin Gil covered this a while back on doing it with Vite. When you define your Vite config, you can like:

  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@import "@/assets/_shared.scss";`
      }
    }
  }

I see webpack can do it too, but I’m not sure if Sass alone can be configured to do it, although I wish it could.

Data Analytics Trends To Watch in 2024

Featured Imgs 29

Technological advances in data analytics have influenced how data is accessed, stored, and managed over the years. Many companies today have robust tools, cutting-edge technology, and flexible ways to insightfully define, identify, and implement new technologies and trends as they emerge each year, improving best practices and shortening bad data cycles.

In this blog post, we explore the latest trends in data analytics services for organizations of all sizes in 2024 and beyond.

How To Handle Optional Values in SwiftData Predicates

Featured Imgs 23

SwiftData has revamped the mechanism for creating data models, incorporating a type-safe mode for predicate creation based on model code. As a result, developers encounter numerous operations involving optional values when constructing predicates for SwiftData. This article will explore some techniques and considerations for handling optional values while building predicates.

From "Inside-Out" to "Outside-In" Transformation

Among the many innovations in SwiftData, the most striking is allowing developers to declare data models directly through code. In Core Data, developers must first create a data model in Xcode's model editor (corresponding to NSManagedObjectModel) before writing or auto-generating NSManagedObject subclass code.

How To Split Exchange Server DAG

Featured Imgs 23

Database Availability Group (DAG) setup in Exchange Server provides full protection and recovery in case of database, network, or server failure. In a DAG, you can have up to 16 mailbox servers hosting a set of databases. This helps provide automatic, database-level recovery in case something happens. 

Sometimes, situations arise when you need to split the Database Availability Group (DAG) and move the mailboxes from one availability group to another. Some common situations are:

Hiding Data in DB2

Featured Imgs 23

In this article, we'll talk about fine-grained access control in DB2 - hiding data that is, in fact, present in the database, but should not be accessible to certain users.

Fine-grained access control is usually done in the database itself as the data is being accessed, but it can also be done between the database server and the database client using a programmable proxy.

The Cost Crisis in Observability Tooling

Featured Imgs 23

The cost of services is on everybody’s mind right now, with interest rates rising, economic growth slowing, and organizational budgets increasingly feeling the pinch. But I hear a special edge in people’s voices when it comes to their observability bill, and I don’t think it’s just about the cost of goods sold. I think it’s because people are beginning to correctly intuit that the value they get out of their tooling has become radically decoupled from the price they are paying. 

In the happiest cases, the price you pay for your tools is “merely” rising at a rate several times faster than the value you get out of them. But that’s actually the best-case scenario. For an alarming number of people, the value they get actually decreases as their bill goes up.

i don´t understand this syntax error when using OpenCV

Category Image 101

This is the error message:

%Run -c $EDITOR_CONTENT
Traceback (most recent call last):
File "<string>", line 6
image = cv2.imread(C:\Users\Audun Nilsen\Pictures\pica.webp)
^
SyntaxError: invalid character in identifier

This is the code:

import cv2 # OpenCV for image processing

image = cv2.imread(C:\Users\Audun Nilsen\Pictures\pica.webp)

Chris’ Corner: Scroll Driven Delight

Category Image 052

I’m pretty hot on Scroll-Driven Animations! What a wonderful idea that we can tie @keyframe animations timelines to scroll positions. And I’m sure the creators of it thought long and hard, because the API makes a ton of things possible. It’s not just “how far the entire page has scrolled”, although that’s possible. The progress through the animation can be tethered either to the scroll position of any element or to the position of an element within a scrollable container. Those are referred to as the Scroll Progress timeline or the View Progress timeline respectively. Slow clap, people.

Bramus Van Damme makes that nicely clear in this overview article. Bramus has been following, working on, creating demos, and writing about this stuff for a long time, and it was a smart move to wrap all that stuff up in a dedicated website for it.

I’m also a big fan of his co-worker Adam’s approach to an intro article here. Adam makes demos that are a smidge more designery and those tend to land with me. And speaking of designery demos, Ryan Mulligan’s beginning explorations are wonderful. He’s got some Polaroid photo style images that “blur in” when they scroll into view and a pair of photos that shuffle themselves as you scroll. I share Ryan’s sentiment that the tools Bramus has built are nearly crucial in understanding this stuff, since all the different keywords and values have such big effects.

These scroll-driven animations tend to be things that are just fun and could easily be thought of as progressive enhancement. So the fact that this is Chrome-only for now isn’t terribly bothersome to me, although it is polyfillable. We also didn’t get scroll-driven animations on the Interop 2024 list, but that doesn’t mean we won’t get Safari or Firefox support this year. Still could happen, just not really a guarantee.

Why do I think this is so cool? It’s not like we absolutely couldn’t do this before. Greensock has a ScrollTrigger plugin that is widely loved and has a pretty sweet API. (Here’s a great Collection.) I don’t think it’s terribly egregious to use JavaScript for these kind of effects, particularly if it makes them more maintainable, performant, or do things impossible any other way. But that’s the thing — when these abilities come back to native web technology like CSS, chances are the performance is going to be great and arguably more maintainable thinking long term as the people familiar with the technology will grow.

Yuriko Hirota did a great job of proving how much more performant using CSS for these types of animations are. The single-threaded nature of DOM interactive JavaScript means that if JavaScript is busy doing anything else, a JavaScript-powered animation is going to suffer from jankiness, that is, jerky and non-smooth animation. Even when JavaScript is quite busy, a CSS powered animation is fine. Those “scroll progress animations” are the classic demo of this web tech. Michelle Barker went deep on those this past year, starting with the basics and getting lovably weird as the article goes on.

Let’s end with a little tip! Bramus mentioned that if you’re setting up a scroll-driven animation that involves a target element and different scrolling element, if it’s not working, there is a good chance…

The culprit: an overflow: hidden sitting somewhere in between the target and the scroller.

It’s always the overflow, isn’t it? I find overflow is usually the culprit in figuring out why a sticky positioned item isn’t working as well. The solution, if you do actually need to deal with hiding overflow, is to use overflow: clip; instead, a relatively new ability. Kevin Powell covered a couple other scenarios where overflow: clip; saves the day, so it’s definitely worth knowing about!

I’ve been playing with Scroll-Driven Animations myself a bit. I wrote one bit about highlighting a bit of text as you scroll down a blog post, something I was inspired by from Lene Saile’s blog. As a response to a reader question, I also figured out how to zoom in images when they come into the viewport as well. Both of those ultimately use the scroll position to control the point in the animation to be at, which I think is usually nice, but I also enjoyed the idea that you can un-tether those things (say, run a 3s animation once an element becomes fully visible) by flipping a --custom-property in a keyframe which triggers a different keyframe, like Ryan Mulligan digs into.

It’s still early days for Scroll-Driven Animations and there are sure to be extremely clever ideas people will find for years. My jaw was already dropped by using them to fit text exactly to a container and to write conditional logic detecting if an element can scroll or not.

The Top 5 Advantages of Internet Marketing

Category Image 023
  1. Targeted Reach: Digital marketing allows you to reach your target audience with pinpoint accuracy. Through techniques such as audience segmentation and personalized messaging, you can deliver tailored content to the right people at the right time, maximizing engagement and conversions.

  2. Cost-Effectiveness: Compared to traditional marketing channels, digital marketing offers a cost-effective way to promote your products or services. With options like social media advertising, pay-per-click campaigns, and email marketing, you can reach a wide audience without breaking the bank.

  3. Measurable Results: One of the most significant advantages of digital marketing is the ability to track and measure your results in real-time. With analytics tools and data-driven insights, you can monitor the performance of your campaigns, identify areas for improvement, and optimize your marketing efforts for maximum impact.

  4. Enhanced Brand Visibility: Digital marketing channels provide endless opportunities to enhance your brand visibility and build a strong online presence. From search engine optimization (SEO) to social media marketing, you can increase brand awareness, attract new customers, and establish your business as an authority in your industry.

  5. Greater Flexibility and Adaptability: In the ever-changing landscape of digital marketing, flexibility and adaptability are key. With the ability to quickly pivot strategies, test new ideas, and respond to market trends in real-time, digital marketing offers unparalleled flexibility compared to traditional marketing methods.