Black Friday 50% OFF! Coupon “BLACKFRIDAY50” Ends in:

0

Days

:

0

Hrs

:

0

Mins

:

0

Secs

Shop now!
WPLake > Learning Hub > 3 Ways to Display Meta Box Fields

3 Ways to Display Meta Box Fields

Explore 3 ways to display Meta Box fields: raw PHP, Advanced Views plugin, and MB Views addon for flexible and streamlined presentation.

Key Points at a Glance

  1. There are three main methods to display Meta Box field values on the front end: using raw PHP code, Advanced Views framework, and MB Views addon.
  2. Displaying field values using raw PHP code is flexible but time-consuming, requiring manual markup creation and data-format conversions.
  3. Advanced Views Lite is a free plugin that simplifies field display and streamlines database queries through smart templates.
  4. MB Views is an official Meta Box addon that works similarly to Advanced Views Lite but comes with an additional cost and lacks some features like template validation.
  5. Both Advanced Views and MB Views utilize the Twig engine and allow the addition of CSS and JS code to customize field display.
  6. Advanced Views offers a File system storage option for storing data within the theme, enabling easy editing and versioning.

Table of Contents

The Meta Box plugin stands out as one of the best meta field plugins available on the market. Its wide range of field types and extensive settings make it an attractive tool for developers. Let's consider three ways in which we can display the values of Meta Box fields on the front end.

1. Display using raw PHP code

This method, while flexible, is also time-consuming and involves manual markup creation. It requires referring to the specific field documentation to understand the return format of each field type.

There are two primary functions to retrieve and display field values:

These functions are used uniformly regardless of the field type, but the output varies depending on the field type.

For instance, for an Image field, the output is an array containing image information, while for a User field, it's a user ID, necessitating the use of built-in WordPress functions to retrieve the user's data.

Tip: Meta Box offers the Builder addon as a replacement for the free Online Configurator. At the bottom of the field group, you can find pre-generated PHP code examples to display fields defined in the current group.

Theme code widget of the MetaBox builder addon
Theme code widget of the Builder addon

2. Using Advanced Views Lite

The Advanced Views Lite plugin offers smart templates for displaying content, featuring built-in post queries and automated template generation. It's a free plugin that seamlessly integrates with a variety of meta field plugins, including Meta Box.

As per the plugin's documentation, it is a versatile and flexible tool that can be utilized independently or in combination with your preferred framework or builder.

The usage of the Advanced Views framework is straightforward. To display our Meta Box fields on the front end, we create a new View and select the target fields from the drop-down menu, then save the settings.

View look of the Advanced Views plugin
View is a smart template responsible for displaying content which includes a Twig template.

Advanced Views Lite automatically generates a Twig template to display the fields, which we can customize according to our needs, including adding CSS and JS code.

Next, we copy the shortcode related to the View we created and paste it in the desired location. That's all there is to it! Visitors can now view the fields displayed in the designated location.

By the way, you don't need to worry about field formats and data conversions anymore. The plugin handles everything dynamically, including Twig rendering and data conversions, by retrieving field values and requesting necessary details from WordPress on the fly.

Pro tip: Advanced Views Lite offers the File system storage option, which stores all data of our Views within our theme. This allows us to edit Twig templates, CSS, and JS directly in our favorite IDE and utilize GIT for versioning.

3. Using MB Views

The MB Views is an official Meta Box addon, which employs a similar approach to the Advanced Views framework. MB Views uses the Twig engine and allows the addition of CSS and JS code.

View's look of the MB Views addon
MB View screen look

The MB Views may sound similar to the Advanced Views framework, so we made a comparison table.

NameTypePriceTwig template with CSS/JSTemplate validationFile system optionQuery post featuresSupported vendors
MB ViewsaddonDeveloper/Lifetime Meta Box bundlesyesnononoWP and Meta Box fields
Advanced Views LitepluginfreeyesyesyesyesWP and Meta Box fields, Woo fields + 2 more vendors

Overall, MB Views and Advanced Views appear similar in terms of displaying Meta Box fields. The main distinction is that the Advanced Views Lite plugin is free, and in addition to simplifying field display, it also streamlines queries to the database.

Conclusions

In summary, the PHP code method offers flexibility but requires manual markup creation and data-format conversions.

Advanced Views Lite, a free option, simplifies field display and streamlines database queries.

MB Views addon works similarly to Advanced Views Lite, however, it misses some features, like template validation, and comes with an additional cost.

Stuck with development or facing an issue?

WPLake offers affordable on-demand website development and design.

No matter the size of your project - contact us now, and we'll get it done for you!

Get assistance now

FAQ mode

/

Learning mode

  1. What are the advantages and disadvantages of using raw PHP code to display field values?

    Using raw PHP code offers flexibility but is time-consuming, requiring manual markup creation and data-format conversions.

  2. How does the Advanced Views plugin simplify the process of displaying field values?

    Advanced Views provides smart templates for field display, streamlines database queries, and offers features like Twig rendering and automatic data conversions.

  3. What is MB Views, and how does it compare to Advanced Views?

    MB Views is an official Meta Box addon that functions similarly to Advanced Views Lite but comes with an additional cost and lacks some features like template validation.

Was this article helpful?

Totally useless

Slightly helpful

Very helpful

Related articles

Content links (21)

About the Author

Maxim Akimov

Certified WordPress expert from Ukraine with over 8 years of experience. Advocate of the BEM methodology and the overall modular approach. Loves sporting activities and enjoys going to the gym and regularly plays table tennis.

0 Comments

    Leave a comment

    Reply to 

    Please be considerate when leaving a comment.

    Not shown publicly


    Got it