enter image description here

I browsed WordPress Codex, and I find something like this →

function is_page_template( $template = '' ) {
    $page_template = get_page_template_slug( get_queried_object_id() );


if ( empty( $template ) )
    return (bool) $page_template;

if ( $template == $page_template )
    return true;

if ( is_array( $template ) ) {
    if ( ( in_array( 'default', $template, true ) && ! $page_template )
        || in_array( $page_template, $template, true )
    ) {
        return true;
    }
}

return ( 'default' === $template && ! $page_template );
}

I think If we paste the above in our functions.php then we will have posts template options, Right?

but what if we want template selection of post type with images like this → This is an image from genesis post page backend.

Does WordPress provide such arrangements? I am a beginner so could not understand How can I accomplish this?

Although the logic is clear to me →

Step 1: Create Meta in the backend that will have some selection options like this → enter image description hereenter image description here

** Step 2 **→
we have to connect our option selected in this meta somehow to print a class.
For example, let u assume the images are in order then if second selected (second image) then echo “sidebar-wrap2”, which is a class.

Currently, this is the HTML →

<aside class="main-sidebar col">
    <?php dynamic_sidebar( 'sidebar1' ); ?>
</aside>





<aside class="main-sidebar col <?php If certain condition true {echo "sidebar-wrap2"} ?> ">
    <?php dynamic_sidebar( 'sidebar1' ); ?>
</aside>

Although I do not know what this certain condition will be, and how to write that.

I am a novice in coding so please do forgive meIf I am unable to present my question correctly. Thanks!

Read more here: WordPress Post Templates Option, but selection by Image format


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: