This feature is not available in the free version of the plugin.
How-to and all required files you will find in the How-to section.
Examples can be found at the bottom of the page.
The Page Section feature can be utilized multiple times on each page, offering the flexibility to create unique and distinctive sections that cater to your specific needs. This can be achieved through a variety of custom options, allowing you to tailor the appearance and layout of each section as desired.
The Page Section can be constructed with various elements, including
It's important positionto note that if an item remains empty, it will not be displayed on the front page. Here are the available options
This checkbox allows you to hide a section without removing it entirely. When selected, the entire section will be hidden rather then removed completely.
Spans the full width of the page.
You can assign as many custom classes from your .css file as needed.
Spans the full width of the page.
If selected, the right column will be displayed as the primary one on mobile devices.
Similar to hiding an entire section but limited to hiding only the right-hand column.
You can align the content inside the column to the left, right, or center.
You can insert custom text or HTML elements (e.g., a custom div) styled within your .css file.
Choose an image from your library.
Instead of an image, you can use SVG graphics.
Specify a subtitle for the internal columns.
Define the content to be displayed inside each of the columns.
The first step is to create a custom PHP block within your child theme or theme directory. In my case, I used the following path: `wp-content -> themes -> child-theme -> parts -> blocks`, dependingwhere I created a PHP file named `section.php`.
Here's the full code of the `section.php` file (or you can download a zip file, link below).
<?php
$data = $args ?? '';
$reversed = '';
$custom_classes = '';
$left_col_al = ' class="to_left"';
$right_col_al = ' class="to_left"';
if( ! empty( $data['second_is_first'] ) ) {
$reversed = ' reversed';
}
if( ! empty( $data['custom_classes'] ) ) {
$custom_classes = ' ' . $data['custom_classes'];
}
if( ! empty( $data['first_column']['align_content'] ) ) {
$left_col_al = ' class="' . $data['first_column']['align_content'] . '"';
}
if( ! empty( $data['second_column']['align_content'] ) ) {
$right_col_al = ' class="' . $data['second_column']['align_content'] . '"';
}
?>
<section class="block-section<?php echo $custom_classes; ?>">
<?php if( ! empty( $data['title'] ) ) { ?>
<h2><?php echo $data['title']; ?></h2>
<?php } ?>
<?php if( ! empty( $data['content'] ) ) { ?>
<div><?php echo $data['content']; ?></div>
<?php } ?>
<div class="content<?php echo $reversed;?>">
<article<?php echo $left_col_al;?>>
<?php if( ! empty( $data['first_column']['custom_output'] ) ) { ?>
<?php echo $data['first_column']['custom_output']; ?>
<?php } ?>
<?php
if( ! empty( $data['first_column']['image'] ) ) {
$img = wp_get_attachment_image_src($data['first_column']['image']['id'], 'large');
echo '<img src="' . $img[0] . '" alt="' . $data['first_column']['image']['name'] . '" title="' . $data['first_column']['image']['name'] . '">';
}
?>
<?php if( ! empty( $data['first_column']['svg'] ) ) { ?>
<div class="icon">
<?php echo $data['first_column']['svg']; ?>
</div>
<?php } ?>
<?php if( ! empty( $data['first_column']['title'] ) ) { ?>
<h3><?php echo $data['first_column']['title']; ?></h3>
<?php } ?>
<?php if( ! empty( $data['first_column']['content'] ) ) { ?>
<div><?php echo $data['first_column']['content']; ?></div>
<?php } ?>
<?php if( ! empty( $data['first_column']['link'] ) ) {
echo lava_get_link( $data['first_column']['link'], 'lava__button' );
} ?>
</article>
<?php if( empty( $data['second_column']['column_is_hidden'] ) ) { ?>
<article<?php echo $right_col_al;?>>
<?php if( ! empty( $data['second_column']['custom_output'] ) ) { ?>
<?php echo $data['second_column']['custom_output']; ?>
<?php } ?>
<?php
if( ! empty( $data['second_column']['image'] ) ) {
$img = wp_get_attachment_image_src($data['second_column']['image']['id'], 'large');
echo '<img src="' . $img[0] . '" alt="' . $data['second_column']['image']['name'] . '" title="' . $data['second_column']['image']['name'] . '">';
}
?>
<?php if( ! empty( $data['second_column']['svg'] ) ) { ?>
<div class="icon">
<?php echo $data['second_column']['svg']; ?>
</div>
<?php } ?>
<?php if( ! empty( $data['second_column']['title'] ) ) { ?>
<h3><?php echo $data['second_column']['title']; ?></h3>
<?php } ?>
<?php if( ! empty( $data['second_column']['content'] ) ) { ?>
<div><?php echo $data['second_column']['content']; ?></div>
<?php } ?>
<?php if( ! empty( $data['second_column']['link'] ) ) {
echo lava_get_link( $data['second_column']['link'], 'lava__button' );
} ?>
</article>
<?php } ?>
</div>
</section>
The second step involves configuring the file responsible for rendering the content on your pages. This may vary depending on your theme, with the default being `page.php`.
Depending on where you want the Page Section to appear, you can insert the following code there:
<?php
$sections = get_field('html_blocks');
if( ! empty( $sections ) ) {
foreach( $sections as $section ) {
if( $section['show_on_page'] ) {
get_template_part('parts/blocks/' . $section['acf_fc_layout'], '', $section);
}
}
}
?>
Now, import the Page Section configuration from the `html_blocks.json` file into your WordPress instance.
When you open any page in the Dashboard (from the Pages menu), you should see the following view. Note that the existing five (-5) sections are provided to help you visualize the final backend output.
Summary: Font-end and Back-end developer, also designer with 25+ years of experience. Currently based in Poland. Eligible to work in the US (US Social Security Number holder) for any employer on W2 / 1099 basis. Utilizes both technical skills and designing aptitude. Lived and worked in Europe, Australia and North America.
PHP CMS HTML5 CSS3 RWD OOP MySQL PDO JS jQuery JSON GIT Bitbucket GitHub Gulp
I've implemented language version feature, ready for additional languages, based on URL modification. Doesn't rely on cookies or sessions and is available via a /{lang} modifier. More about languages
Zaimplementowałem wersję językową, gotową na dodanie kolejnych języków, opartą na modyfikacji URL, która nie korzysta z plików cookie ani sesji. Wersja językowa dostępna jest przez modyfikator /{język}. Więcej o językach