php - WordPress 页面内容风格与编辑器风格不同

标签 php css wordpress wordpress-theming custom-wordpress-pages

<分区>

我正在开发一个 WordPress 主题。对于我在编辑器中的页面内容,它看起来像这样:

editor

这就是我想要的风格。但是,当我在page.php中输出时,样式就变成了这样:

output

如您所见,文本对齐方式和字体变得完全不同。我应该如何处理我的主题才能使输出样式看起来与编辑器中的样式完全相同?谢谢

这是我的 page.php 代码:

<?php get_header(); ?>

<div id="content" class="row card index-card" role="main">
    <div class="col-xs-12">
        <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
            <div class="entry-header">
                <h3 class="page-title entry-title" item-prop="headline">
                     <?php the_title(); ?>
                </h3>
            </div>
            <div class="entry-content" item-prop="text">
                <?php echo $post -> post_content; ?>
            </div>
        </article>
    </div>
</div>

<?php get_footer(); ?>

和functions.php:

<?php

add_theme_support('post-formats');
add_theme_support('post-thumbnails');

// Adding stylesheets and js libraries
function installLibraries() {
    // CSS
    wp_enqueue_style('bootstrap', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css');
    wp_enqueue_style('bootstrap-theme', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css');
    wp_enqueue_style('slick', 'https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick.min.css');
    wp_enqueue_style('slick-theme', 'https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick-theme.min.css');
    wp_enqueue_style('navbar-style', get_template_directory_uri() . '/css/navbar.css');
    wp_enqueue_style('footer-style', get_template_directory_uri() . '/css/footer.css');
    wp_enqueue_style('style', get_stylesheet_uri());

    // JS
    wp_enqueue_script('jquery', get_template_directory_uri() . '/js/jquery.min.js', array('jquery'), null, true);
    wp_enqueue_script('slick', 'https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.6.0/slick.min.js', array('jquery'), null, true);
    wp_enqueue_script('masonry', 'https://unpkg.com/masonry-layout@4/dist/masonry.pkgd.min.js', array('jquery'), null, true);
    wp_enqueue_script('bootstrap', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js', array('jquery'), null, true);
    wp_enqueue_script('index', get_template_directory_uri() . '/js/index.js', array('jquery'), null, true);
}
add_action('wp_enqueue_scripts', 'installLibraries');


// Adding menu support as well as walker
require_once('wp-bootstrap-navwalker.php');
register_nav_menus(array(
    'main_menu' => __('Main Menu', 'mw-material')
));
// Add search at the end
function nav_search($items, $args) {
    // If this isn't the primary menu, do nothing
    if( !($args->theme_location == 'main_menu') ) {
            return $items;
        }
    // Otherwise, add search form
    return $items . '<div class="search-dropdown">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                <img class="search-icon" alt="search" src='. get_template_directory_uri() . '/img/icons/search.png?>
            </a>
            <ul class="dropdown-menu">
                <li>' . get_search_form(false) .'</li>
            </ul>
        </div>';
}
add_filter('wp_nav_menu_items', 'nav_search', 10, 2);

这个特定问题更多是针对 WordPress

最佳答案

在 css 中将你的设置为 float:left。 这应该有效:http://jsfiddle.net/cornelraiu/kYDgL/1016/

How to wrap text around an image using HTML/CSS

添加

.entry-content img{float:left}

关于php - WordPress 页面内容风格与编辑器风格不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44836957/

上一篇:html - 创建给定模板的正确方法

下一篇:javascript - GoJS 中链接上方的图标

相关文章:

php - 在 Laravel Transformers 上使用中间件调用 null 上的成员函数 createData()

php - 如何在ajax调用后使用javascript刷新页面的Div部分

html - Bootstrap 导航栏元素适合内容的宽度

css - 允许跨度在 Twitter Bootstrap 中溢出行

html - 使用 CSS 屏蔽 div

javascript - 当 jQuery 事件运行时,如何触发谷歌地图调整大小?

php - 单击按钮调用函数,获取 url

php - 链接到新页面并打开特定模式

html - 无论屏幕大小如何,媒体查询都会触发

php - 无法在服务器上运行 Zend Framework 2 - 找不到类 'Zend\Mvc\Application'