Отображение избранного изображения слева для выдержки из сообщения Wordpress - PullRequest
0 голосов
/ 16 июня 2020

Я новичок в разработке Wordpress и столкнулся с небольшой проблемой. Когда загружается первая страница, я хочу, чтобы сообщения, содержащие избранные изображения, отображали их в виде эскиза, плавающего слева и содержащего дополнительную информацию. Когда человек нажимает на ссылку «Читать дальше» до go полной записи блога, я хочу, чтобы это же изображение было полноразмерным. У меня есть поддержка в моей настраиваемой теме, и я добавил ее в div для достижения плавающего положения, но ничего не работает.

Вот чего я хочу достичь:

Вот мои функции. php код:

    <?php
    //Add theme support
    add_theme_support( 'title-tag' );
    add_theme_support( 'post-thumbnails' );
    add_theme_support( 'post_format', ['aside', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio', 'chat'] );
    add_theme_support( 'html5' );
    add_theme_support( 'automatic-feed-links' );
    add_theme_support( 'custom-background' );
    add_theme_support( 'custom-header' );
    add_theme_support( 'custom-logo' );
    add_theme_support( 'customize-selective-refresh-widgets' );
    add_theme_support( 'starter-content' );

    // Load in our CSS
    function justablog_enqueue_styles() {

      wp_enqueue_style( 'main-css', get_stylesheet_directory_uri() . '/style.css', [], time(), 'all' );

    }
    add_action( 'wp_enqueue_scripts', 'justablog_enqueue_styles' );

    //Would load  your javascripts files from js folder here

    // Register Menu Locations
    register_nav_menus( [
      'main-menu' => esc_html__( 'Main Menu', 'justablog' ),
    ]);

    //Setup Widget Areas
    function justablog_widgets_init() {
    register_sidebar([
      'name' => esc_html__( 'Main Sidebar', 'justablog'),
      'id'  => 'main-sidebar',
      'description' => esc_html__('Add widgets for main sidebar here', 'justablog')
    ]);
    }


    add_action( 'widgets_init', 'justablog_widgets_init');

    //custom image sizes for thumbnails
    ?>

Вот мой первая страница. php код:

 <?php get_header(); ?>
      <div class="leftcolumn">
        <div class="card">
          <?php if ( have_posts() ) : ?>
    <?php while ( have_posts() ) : the_post(); ?>
      <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <div class="post-header">
           <h2 class="post-h2"><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
           <div class="date"><?php the_time( 'F d, Y' ); ?></div>
           <div class="author"><?php the_author(); ?></div>
        </div><!--end post header-->
        <div class="entry clear">
          <div class="image-small">
            <?php if ( function_exists( 'add_theme_support' ) ) the_post_thumbnail(); ?>
          </div>
           <?php the_excerpt(); ?>
           <?php wp_link_pages(); ?>

         </div>
        <!--end entry-->
        <div class="post-footer">
          <?php edit_post_link(); ?>
           <div class="comments"><?php comments_popup_link( 'Leave a Comment', '1 Comment', '% Comments' ); ?></div>
        </div><!--end post footer-->
        </div><!--end post-->
    <?php endwhile; /* rewind or continue if all posts have been fetched */ ?>
        <div class="navigation index">
           <div class="alignleft"><?php next_posts_link( 'Older Entries' ); ?></div>
           <div class="alignright"><?php previous_posts_link( 'Newer Entries' ); ?></div>
        </div><!--end navigation-->
    <?php else : ?>
    <?php endif; ?>

      </div>
    </div>
      <?php get_footer(); ?>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...