Answer the question
In order to leave comments, you need to log in
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
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; ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question