无法在 wordpress 上将我的 html 编辑为 wordpress 主题

     2023-03-05     98

关键词:

【中文标题】无法在 wordpress 上将我的 html 编辑为 wordpress 主题【英文标题】:Can not edit my html to wordpress theme on wordpress 【发布时间】:2016-08-05 16:04:52 【问题描述】:

我是 WordPress 新手。我最近制作了自己的 html 网站并将其转换为 WordPress。它在 WordPress 中运行良好。但是有一个问题,那就是我无法通过 WordPress 更改网站的内容。也许是因为我在我的主题的 index.php 中编码了 html,但我不确定这是否有任何效果。 现在我的主题有以下文件:

    index.php

    footer.php

    header.php

    style.css

    screenshot.png

    css(文件夹)

    js(文件夹)

    字体(文件夹)

    img(文件夹)

我们将不胜感激任何形式的帮助。

【问题讨论】:

您要编辑 WordPress 网站的哪个部分?每个部分都需要一个模板。 你用的是什么主题?? 我只是想通过 wordpress 编辑我的页面内容。而且我创建的每个新页面看起来都一样。我知道这是因为我将 html 编码为 index.php 文件。 EntrePrAmar 我没有使用任何主题。我用自己的自定义 html 文件制作了 wordpress 主题。 @SHARJEELIMTIAZ,是的,模板是 php 文件,而 WP 页面是使用这些模板呈现的动态内容。请参阅下面的答案。 【参考方案1】:

不要对 index.php 中的所有 html 进行硬编码,而是使用 WP 循环创建模板,然后使用这些模板在 Wordpress Admin 中创建页面。例如,如果您使用的是 25 个 Wordpress 主题,您的主模板可能类似于:

 <?php
/**
 * The main template file
 * Template Name: Front_Page
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * e.g., it puts together the home page when no home.php file exists.
 *
 * Learn more: @link https://codex.wordpress.org/Template_Hierarchy
 *
 * @package WordPress
 * @subpackage Twenty_Fifteen
 * @since Twenty Fifteen 1.0
 */
    get_header(); ?>

    <div id="primary" class="content-area">
        <main id="main" class="site-main" role="main">

        <?php if ( have_posts() ) : ?>

            <?php if ( is_home() && ! is_front_page() ) : ?>
                <header>
                    <h1 class="page-title screen-reader-text"><?php single_post_title(); ?></h1>
                </header>
            <?php endif; ?>

            <?php
            // Start the loop.
            while ( have_posts() ) : the_post();

                /*
                 * Include the Post-Format-specific template for the content.
                 * If you want to override this in a child theme, then include a file
                 * called content-___.php (where ___ is the Post Format name) and that will be used instead.
                 */
                get_template_part( 'content', get_post_format() );

            // End the loop.
            endwhile;

            // Previous/next page navigation.
            the_posts_pagination( array(
                'prev_text'          => __( 'Previous page', 'twentyfifteen' ),
                'next_text'          => __( 'Next page', 'twentyfifteen' ),
                'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentyfifteen' ) . ' </span>',
            ) );

        // If no content, include the "No posts found" template.
        else :
            get_template_part( 'content', 'none' );

        endif;
        ?>

        </main><!-- .site-main -->
    </div><!-- .content-area -->

<?php get_footer(); ?>

然后创建一个首页:在页面中选择添加新页面。将其命名为“家”。将您的 html 动态内容放在内容区域中。选择您之前创建的模板 Front_Page(从右侧栏)。更多详细信息请参见 WP codex 链接:WordPress Static Front Page Process

现在要更改页面的内容,您只需在 WP 管理面板中编辑页面。希望这会有所帮助。

编辑 1:您可以像传统方式一样将样式表和 Js 文件排入头文件中,也可以通过主题的 function.php 进行。有关信息,请参阅 Including CSS & JavaScript 和 wp_enqueue_style。

编辑2:是的,最好使用现有主题并对其进行自定义,或者使用现有主题WP Child Theme制作您自己的子主题

【讨论】:

这个“模板”文件的具体名称是什么。是page.php吗?? @SHARJEELIMTIAZ,以上是主模板index.php的例子

在 iOS 上将 Wordpress JSON 解析为 UITableView

】在iOS上将WordpressJSON解析为UITableView【英文标题】:ParseWordpressJSONintoUITableViewoniOS【发布时间】:2012-12-2116:48:15【问题描述】:我正在尝试解析来自thisURL的JSON,这是来自Wordpress的JSON输出。由于某种原因,UITableView中没有输出。... 查看详情

在 MacOS 上将 Vapor 编译为独立应用程序

】在MacOS上将Vapor编译为独立应用程序【英文标题】:CompilingVaporasStandaloneApponMacOS【发布时间】:2018-02-1021:05:44【问题描述】:我想用我的代码将Vapor编译为MacOS应用程序,这样我就可以将它放在内部服务器上(拖动并单击以启动... 查看详情

是否可以在 function.php wordpress 上将脚本 src 排入队列?

】是否可以在function.phpwordpress上将脚本src排入队列?【英文标题】:Isthatpossibletoenqueueascriptsrconfunction.phpwordpress?【发布时间】:2015-06-2520:48:21【问题描述】:我的首页模板上有JavaScript,如下所示,我想将其从首页模板中删除并... 查看详情

Tooltipster 无法在移动设备上运行 - Wordpress

】Tooltipster无法在移动设备上运行-Wordpress【英文标题】:Tooltipsternotworkingonmobiledevices-Wordpress【发布时间】:2017-07-1922:17:18【问题描述】:Tooltipsterjquery插件被加载以触发工具提示“悬停”状态。在移动设备上时,“悬停”触发器... 查看详情

在树莓派上将 libffi 编译为静态库

】在树莓派上将libffi编译为静态库【英文标题】:compilelibffiasstaticlibraryonraspberrypi【发布时间】:2015-11-2404:04:55【问题描述】:我正在尝试编译libffi-3.2.1的静态库,但没有成功。cdlibffi-3.2.1./configure--prefix=/home/pi/libraries/libffi--enable... 查看详情

使用自定义 CSS 在 Wordpress.com 主题上将标题扩展到全宽 [关闭]

】使用自定义CSS在Wordpress.com主题上将标题扩展到全宽[关闭]【英文标题】:ExtendheadertofullwidthonWordpress.comthemewithcustomCSS[closed]【发布时间】:2014-11-2808:03:44【问题描述】:我希望在托管在Wordpress.com上的客户博客上将标题图像扩展... 查看详情

无法在我的 wordpress 网站上安装 jetpack

】无法在我的wordpress网站上安装jetpack【英文标题】:Unabletoinstalljetpackonmywordpresswebsite【发布时间】:2019-12-2311:36:42【问题描述】:尝试在我的wordpress网站上安装jetpack时,我收到此消息:Jetpack服务器无法与您的站点通信http://xx[IX... 查看详情

如何在我的网站上将 WMD markdown 语法转换为 HTML?

】如何在我的网站上将WMDmarkdown语法转换为HTML?【英文标题】:HowdoiconvertWMDmarkdownsyntaxtoHTMLonmysite?【发布时间】:2010-10-2006:29:12【问题描述】:我正在使用django并在我的网站上实现WMD,我只是想知道如何将markdown语法转换为HTML以... 查看详情

如何在 Swift 上将 HTML 代码加载到 WebView

】如何在Swift上将HTML代码加载到WebView【英文标题】:HowcanIloadHTMLCodetoWebViewonSwift【发布时间】:2020-04-2215:41:34【问题描述】:我在***上搜索了如何在swift上实现我的webview以显示html代码并且已经找到了一些东西。但它不起作用。... 查看详情

我无法在 localhost 上激活我的 WordPress 插件

】我无法在localhost上激活我的WordPress插件【英文标题】:Ican\'tactivatemyWordPresspluginonlocalhost【发布时间】:2013-01-0218:39:51【问题描述】:我正在尝试激活在localhost上运行的WordPress上的一个小插件,但它遇到以下错误:插件在激活... 查看详情

无法在 ubuntu 11.1 上将 curl 与 PHP 一起使用

】无法在ubuntu11.1上将curl与PHP一起使用【英文标题】:CannotusecurlwithPHPonubuntu11.1【发布时间】:2014-07-0914:13:55【问题描述】:我正在尝试在我的ubuntu11.1服务器上使用curl。在我的脚本中,我有以下内容:$ch=curl_init();但是当我运行... 查看详情

我的 wordpress 网站无法在 MS Edge / IE 上运行。

】我的wordpress网站无法在MSEdge/IE上运行。【英文标题】:Mywordpresswebsitedoesn\'tworkonMSEdge/IE.【发布时间】:2017-09-2401:51:42【问题描述】:最近我一直在为我的客户开发一个网站。我想明确一点,我不是专业的网络开发人员,我是一... 查看详情

无法在 Localhost (Xampp) Wordpress 站点中裁剪我的图标

】无法在Localhost(Xampp)Wordpress站点中裁剪我的图标【英文标题】:CannotcropmyfaviconinLocalhost(Xampp)Wordpresssite【发布时间】:2021-08-1114:11:22【问题描述】:嗨。最近我在localhostXampp服务器上做一个Wordpress项目。尽管我在裁剪图标时遇到... 查看详情

如何在 Android 设备上将 WAV 编码为 mp3

】如何在Android设备上将WAV编码为mp3【英文标题】:HowtoencodeaWAVtoamp3onaAndroiddevice【发布时间】:2010-09-0410:50:49【问题描述】:我已经简化了我的问题并提供了赏金:有哪些选项可用于在Android设备上将原始PCM音频数据压缩为mp3。我... 查看详情

如何在 Android 设备上将 WAV 编码为 mp3

】如何在Android设备上将WAV编码为mp3【英文标题】:HowtoencodeaWAVtoamp3onaAndroiddevice【发布时间】:2011-04-0804:50:00【问题描述】:我已经简化了我的问题并提供了赏金:有哪些选项可用于在Android设备上将原始PCM音频数据压缩为mp3。我... 查看详情

无法在主页以外的其他页面中显示图像(wordpress/html/css)

】无法在主页以外的其他页面中显示图像(wordpress/html/css)【英文标题】:TroubleshowingimagesinotherpagesthanHome(wordpress/html/css)【发布时间】:2012-11-2901:59:44【问题描述】:您好,我有一个为客户做的小网站,我使用了一个html/css网站... 查看详情

在 Wordpress 中居中特色图片 [关闭]

】在Wordpress中居中特色图片[关闭]【英文标题】:CenteringfeaturedimageinWordpress[closed]【发布时间】:2019-10-1514:24:04【问题描述】:我想在我的网站上将Wordpress特色图片居中:https://link.do/ibXD8我在主题属性中找不到合适的选项。【问... 查看详情

无法在 XAMPP 中安装 wordpress

】无法在XAMPP中安装wordpress【英文标题】:CannotinstallwordpressinXAMPP【发布时间】:2015-10-2802:00:42【问题描述】:我已成功安装XAMPP。我的Apache和MySQL服务器运行良好。当我在进度条已满时安装wordpress时,没有问题。但是当最后的进... 查看详情