Home Forums Themes Support Formota background on passwrod protect page

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #3592

    how can I put a background image on a page protected by a password (http://rafilm.pl/2018-07-14-katarzyna-lukasz/) I need to put a different picture on each such page. Is it possible?


    Thanks for your question.
    In this case It is possible, However you need customize code.
    Step 1: You need add new metabox for select image background for each post follow this tutorial: https://harutheme.com/forums/topic/add-new-metabox-circle-single-video-film-actor-director/
    In this case you you can go after line 719 and add the code like this:

                    'title'      => esc_html__( 'Post Background Image', 'formota' ),
                    'id'         => 'haru_' .'meta_box_post_background_image',
                    'post_types' => array('post', 'page'),
                    'fields'     => array(
                            'name'             => esc_html__('Background Image', 'formota'),
                            'id'               => 'haru_' . 'post_background_image',
                            'type'             => 'image_advanced',
                            'max_file_uploads' => 1,
                            'desc'             => esc_html__( 'Select an image background for post', 'formota' )

    It will become like this: http://prntscr.com/o3gjun
    Step 2: You can use child theme follow this topic tutorial to customize template display: https://harutheme.com/forums/topic/customize-wordpress-theme-using-child-theme/
    The code to help you get background image url is:
    $bg_image_id = get_post_meta( get_the_ID(), ‘haru_post_background_image’, true );
    $bg_image_url = wp_get_attachment_image_src( $bg_image_id, ‘full’ );
    Step 3:
    Display this image as background of DIV wrap post or page. Example we use this as background of article tag in templates/single/content.php

    $bg_image_id = get_post_meta( get_the_ID(), 'haru_post_background_image', true );
    $bg_image_url   = wp_get_attachment_image_src( $bg_image_id, 'full' );
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?> style="background-image: url('<?php echo esc_url( $bg_image_url ); ?>');">

    It will like this: http://prntscr.com/o3gobz
    Hope this help!


Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.