V
V
Vladimir2021-10-01 14:59:05
WordPress
Vladimir, 2021-10-01 14:59:05

Is it possible to split some pages into multiple blocks in Wordpress?

I have several blocks with texts and pictures on the main page. Question: how to edit these blocks? Here is my homepage in my admin panel. I need to be able to edit texts there. Rather, there were several blocks with text input. Is it real to do?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Valentin Popov, 2021-10-01
@DHARMA373

Use the ACF plugin.
For example, you have a block on the page with the following data:
Title
Image
Description
Install the ACF plugin Go
to the Field Groups tab.
In this input create a name, for example Fields for the main page At the
bottom, select Page template = Your template on which the markup of your main page is placed. For example, it will be Template front page
After that, click add field. And you create your fields and assign them a slug by which you will refer to them in the code.
In code, this is output as follows:

<?php if ( $text = get_field( 'header' ) ) : ?>
  <?php echo esc_html( $text ); ?>
<?php endif; ?>
<?php
$image = get_field( 'image' );
if ( $image ) : ?>
  <img src="<?php echo esc_url( $image['url'] ); ?>" alt="<?php echo esc_attr( $image['alt'] ); ?>" />
<?php endif; ?>
<?php if ( $desc = get_field( 'description' ) ) : ?>
  <?php echo esc_html( $desc ); ?>
<?php endif; ?>

After that, go to the page in the admin and you will have a tab with fields there, fill them with data and that's it.

A
Alexander, 2021-10-01
@apisklov

Can. ACF
plugin .

A
Artem Zolin, 2021-10-01
@artzolin

Alternatives to Carbon Fields and MetaBox

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question