当前位置: 首页 > news >正文

做网站用的产品展示横幅网站建设的维护与更新

做网站用的产品展示横幅,网站建设的维护与更新,福田专业做网站公司,网络推广策划案该怎么写要为WordPress注册一个Carousel轮播区块#xff0c;你可以创建一个自定义Gutenberg块。以下是一个简单的示例#xff0c;说明如何创建一个Carousel轮播区块#xff1a; 1. 在你的主题目录中创建一个名为carousel-block的子文件夹。在这个文件夹中#xff0c;创建一个名为c…要为WordPress注册一个Carousel轮播区块你可以创建一个自定义Gutenberg块。以下是一个简单的示例说明如何创建一个Carousel轮播区块 1. 在你的主题目录中创建一个名为carousel-block的子文件夹。在这个文件夹中创建一个名为carousel-block.php的文件。将以下代码添加到该文件中 php ?php /* Plugin Name: Carousel Block Description: A simple Carousel block for WordPress Gutenberg. Version: 1.0 Author: Your Name Author URI: https://example.com License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html */ function carousel_block_register() {     wp_register_script(         carousel-block-editor,         plugins_url(carousel-block-editor.js, __FILE__),         array(wp-blocks, wp-element, wp-editor, wp-components),         filemtime(plugin_dir_path(__FILE__) . carousel-block-editor.js)     ); wp_register_style(         carousel-block-editor,         plugins_url(carousel-block-editor.css, __FILE__),         array(),         filemtime(plugin_dir_path(__FILE__) . carousel-block-editor.css)     ); register_block_type(carousel-block/carousel, array(         editor_script carousel-block-editor,         editor_style carousel-block-editor,     )); } add_action(init, carousel_block_register); 2. 在carousel-block文件夹中创建一个名为carousel-block-editor.js的文件并将以下代码添加到该文件中 javascript const { registerBlockType } wp.blocks; const { RichText, MediaUpload } wp.editor; const { Button } wp.components; registerBlockType(carousel-block/carousel, {     title: Carousel,     icon: images-alt,     category: common,     attributes: {         title: {             type: string,             source: html,             selector: h2,         },         imageUrl: {             type: string,             source: attribute,             attribute: src,             selector: img,         },         imageId: {             type: number,         },     },     edit({ attributes, setAttributes }) {         const { title, imageUrl, imageId } attributes; const onSelectImage (image) {             setAttributes({                 imageUrl: image.url,                 imageId: image.id,             });         }; return (             div classNamecarousel-block                 h2Carousel/h2                 RichText                     tagNameh2                     value{title}                     onChange{(value) setAttributes({ title: value })}                     placeholderTitle...                 /                MediaUpload                     onSelect{onSelectImage}                     typeimage                     value{imageId}                     render{({ open }) (                        Button onClick{open}                             {imageUrl ? Edit Image : Select Image}                         /Button                     )}                 /                 {imageUrl img src{imageUrl} alt{title} /}             /div         );     },     save({ attributes }) {         const { title, imageUrl } attributes;         return (             div classNamecarousel-block                 h2{title}/h2                 {imageUrl img src{imageUrl} alt{title} /}             /div         );     }, }); 3. 在carousel-block文件夹中创建一个名为carousel-block-editor.css的文件并将以下代码添加到该文件中 css .carousel-block {     display: flex;     flex-direction: column;     align-items: center;     padding: 20px;     background-color: #f0f0f0;     border: 1px solid #ccc; } .carousel-block h2 {     margin-bottom: 10px; } .carousel-block img {     max-width: 100%;     height: auto; } 4. 在你的主题的functions.php文件中添加以下代码以激活Carousel轮播区块插件 php function my_theme_register_carousel_block() {     include_once(carousel-block/carousel-block.php); } add_action(init, my_theme_register_carousel_block); 现在你应该能够在WordPress编辑器中看到一个名为“Carousel”的新块。你可以在编辑器中添加Carousel块设置标题和图片然后将其添加到页面中。 请注意这个示例仅用于演示目的实际项目中可能需要更多的功能和优化。在使用此插件时请确保遵循WordPress最佳实践和安全性原则。 来源 https://www.mymoban.com/wp/
http://www.hkea.cn/news/14308989/

相关文章:

  • 马鞍山做网站网页图片大全
  • 内部门户网站建设方案wordpress 花园
  • 可以不使用备案的网站名吗张店区网站建设特点有哪些 谢谢
  • 德惠市建设局网站苏州做网站0512jinyan
  • 襄阳网站建设公司哪家好南宁哪个网络公司建网站好
  • 网站建站系统程序美术生最吃香的专业
  • 做用户名验证的网站服务器外贸个人网站
  • 深圳网站建设公司首选未来的软件开发方向是什么
  • 网站开发实战asp制作视频教程ueditor wordpress html被转义
  • 达州市住房和建设厅网站vultr wordpress
  • 国外网站需要备案吗广州公司网站建设
  • 大连零基础网站建设培训中心佳木斯城乡建设局官方网站
  • 口碑好的购物网站建设wordpress装主题失败
  • WordPress网站hym地图株洲专业网站排名优化
  • 哪些网站做黑名单象山关键词seo排名
  • 网站建设工作内容投票网站怎么制作
  • 无障碍网站建设方案惠州建设局网站
  • 漳州做网站简书 wordpress
  • 设计企业网站哪家好南通网站seo报价
  • 我的世界查询建筑网站网站内做营销活动使用工具
  • 网站建设用cms网站环境配置
  • 如何做网站授权网址三桥网站建设
  • 凡科建站是什么呼和浩特商城网站建设
  • 网站建设推广销售好做吗网站需要备案吗
  • 怎样在网上做网站wordpress get图片
  • 有了域名怎么做网站重庆就业网
  • 厦门网站建设缑阳建视频封面制作网站
  • 邮箱注册过的网站查询做个淘宝客网站怎么做的
  • vs2012做网站网站固定头部
  • 网站总体设计怎么写wordpress免费单页主题