wordpress本地做好的网站放在服务器上CSS样式不生效了

之前也做好的主题也没有生效,首页只是能看到文字,看不到图片,数据库该改的地方
链接都已经改过来了,但是还是看不到图片,查看源代码,居然还发现有localhost的存在
不知道该怎弄了。。

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Wordpress CSS无法正常工作

<div class="post-text" itemprop="text"> <p>My WordPress themes are not working. My WordPress is 4.9.3, everything was working fine until the server admin moved the directory. So I basically, edited the DB home and site URL values, and the website is functioning, except the themes. All of them I even tried the Twenty FifteenVersion and it's not working too. What is not working exactly is the CSS, although when I check through to inspect if the files are loaded, and when I download them they are correct. So the themes are sort of HTML only and messed up. I checked/corrected the file permissions, and still, it's not working. </p> </div>

在Wordpress中的某些管理页面上自定义css和JS

<div class="post-text" itemprop="text"> <p>I created a plugin to export some specific content in Wordpress ( called <strong>cav</strong> and located in <strong>/wp-content/plugins/cav</strong> ) and I added its admin menu link in the Tools main menu as follows:</p> <pre><code>define( 'CAV_DIR', plugin_dir_path( __FILE__ ) ); define( 'CAV_URL', plugins_url()."/cav" ); function cavlfo_admin_enqueue($hook) { global $post; if ( $hook == 'post-new.php' || $hook=='tools.php?page=CAV' ) { wp_enqueue_style( 'cavlfo_style', CAV_URL. '/css/cav.css' ); wp_enqueue_style( 'cavlfo_targetted', CAV_URL.'/css/targettedcss.css' ); wp_enqueue_script( 'cavlfo_targetted', CAV_URL.'/js/targetted.js', array("jquery") ); } } add_action( 'admin_enqueue_scripts', 'cavlfo_admin_enqueue' ); </code></pre> <p>All this works fine when I used </p> <p><code>if( $hook == 'post-new.php' || $hook=='tools.php' ){ . . .}</code> </p> <p>but I want it to work ONLY when it's actually </p> <p><code>if( $hook == 'post-new.php' || $hook=='tools.php?page=CAV' ){ . . .}</code> (Only on the page is CAV )</p> <p>Any suggestion? </p> </div>

Wordpress无法加载样式:无法加载资源:服务器响应状态为404(未找到)

<div class="post-text" itemprop="text"> <p>I'm trying to convert HTML static website to WordPress. I'm stuck at the very beginning, where I need to load all my styles from css folder in my <em>function.php</em> </p> <pre><code>&lt;?php // Loading styles add_action( 'wp_enqueue_scripts', 'load_styles' ); function load_styles() { wp_enqueue_style( 'animate', get_template_directory_uri() . '/css/animate.css' ); wp_enqueue_style( 'font-awesome', get_template_directory_uri() . '/css/font-awesome.css' ); wp_enqueue_style( 'font-awesome2', get_template_directory_uri() . '/css/font-awesome2.css' ); wp_enqueue_style( 'framework', get_template_directory_uri() . '/css/framework.css' ); wp_enqueue_style( 'owl', get_template_directory_uri() . '/css/owl.theme.css' ); wp_enqueue_style( 'style', get_template_directory_uri() . 'style.css' ); } ?&gt; </code></pre> <p>Here are all my files located in the following directory:</p> <p><img src="https://i.stack.imgur.com/IUnTi.png" alt="enter image description here"></p> <p>And then I'm trying to inspect element in Google Chrome I got a bunch of errors that are saying the same thing: <em>Failed to load resource: the server responded with a status of 404 (Not Found)</em></p> <p>In my <em>header.php</em> I'm calling <code>&lt;?php wp_head(); ?&gt;</code> right before the <code>&lt;/head&gt;</code> TAG. In my <em>index.php</em> file I'm calling <code>&lt;?php get_header(); ?&gt;</code> </p> <p>I tried to move <code>add_action( 'wp_enqueue_scripts', 'load_styles' );</code> to the bottom;</p> <p>I tried to set permissions for my folders in Filezilla to 777;</p> <p>I tried to use <code>get_stylesheet_uri()</code> instead of <code>get_template_directory_uri()</code>;</p> <p>And I don't know what I supposed to do next.</p> </div>

无法在wordpress主题上加载自定义CSS

<div class="post-text" itemprop="text"> <p>I've created an HTML/CSS design and now I'm trying to convert it to a WordPress template. I've created the stylesheet and function.php.</p> <p>I have the following code in my function.php</p> <pre><code>&lt;?php function test_theme(){ wp_enqueue_style("customstyle", get_stylesheet_uri() ) } add_action( 'wp_enqueue_scripts', 'test_theme' ); </code></pre> <p>I've added this to my header.php</p> <pre><code>&lt;?php wp_head(); ?&gt; </code></pre> <p>For some reason after adding that WordPress has added a few scripts and links to the header but not my custom stylesheet </p> <p>What am I doing wrong? I'm also new to wordpress development and following a youtube video.</p> </div>

PHP更改CSS样式

<div class="post-text" itemprop="text"> <p>I'm trying to hide a login button if the user is logged in. Due to the clients <strong>Wordpress</strong> setup, I'm not able to directly edit the button HTML. </p> <p><strong>Button HTML (unable to edit):</strong></p> <pre><code>&lt;li id="menu-item-153" class="menu-item menu-item-type-custom menu-item object-custom current-menu-item current_page_item menu-item-home menu-item-153"&gt; &lt;a href="#"&gt; &lt;span id="SignUp" class="et_pb_more_button et_pb_button"&gt; &lt;p&gt;SIGN UP&lt;/p&gt; &lt;/span&gt; &lt;/a&gt; &lt;/li&gt; </code></pre> <p>My thoughts was to write a simple PHP if statement to change the CSS within the header.</p> <pre><code>&lt;?php if ( is_user_logged_in() ) { ?&gt; &lt;style type="text/css"&gt; #menu-item-153 { display: none; } &lt;/style&gt; &lt;?php } ?&gt; </code></pre> <p>However, the PHP echo outputs on the page but it doesn't change the CSS. </p> <p>On inspection, it looks like the following:</p> <p><a href="https://i.stack.imgur.com/CDbmM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CDbmM.png" alt="enter image description here"></a></p> <p>Any suggestions here? Thanks!</p> <p><strong>Edit:</strong></p> <p>Just tried using a jQuery way with no luck:</p> <pre><code>&lt;script&gt; $( 'menu-item-153' ).css('display', 'none'); &lt;/script&gt; </code></pre> </div>

我无法在我的wordpress网站的插件中加载自定义样式

<div class="post-text" itemprop="text"> <p>I am trying to call my custom styles in my wordpress plugin. I tried the wp_enqueue methods but i could not find my style sheet getting loaded.</p> <p>I have tried examples from stackoverflow itself but it is not working for me. I checked the enqued styles using debug bar - dependancy tool and cannot find the styles in that too. Please check the link for my enqued styles . <a href="https://i.stack.imgur.com/p7fP6.png" rel="nofollow noreferrer">debug bar</a> The following are the two different ways, i tried to load my css.</p> <pre><code>function wp_adding_styles1() { wp_enqueue_style('my_eastern_charts_stylesheet', plugin_dir_url(__FILE__) . 'eastern_charts_stylesheet.css'); } add_action('wp_enqueue_scripts', 'wp_adding_styles1'); function wpb_adding_styles() { wp_register_style('my_stylesheet', plugins_url('eastern_charts_stylesheet.css', __FILE__)); wp_enqueue_style('my_stylesheet'); } add_action( 'wp_enqueue_scripts', 'wpb_adding_styles' ); </code></pre> <p><a href="https://i.stack.imgur.com/EKKYy.png" rel="nofollow noreferrer">Directory Structure</a></p> </div>

WordPress主题中的.css引用在哪里?

<div class="post-text" itemprop="text"> <p>I am pretty new in WordPress and I have the following doubt about how link a CSS file into a WP theme.</p> <p>For example this is the <strong>header.php</strong> file of the <strong>TwentyTwelve</strong> preinstalled template:</p> <pre><code>&lt;?php /** * The Header template for our theme * * Displays all of the &lt;head&gt; section and everything up till &lt;div id="main"&gt; * * @package WordPress * @subpackage Twenty_Twelve * @since Twenty Twelve 1.0 */ ?&gt;&lt;!DOCTYPE html&gt; &lt;!--[if IE 7]&gt; &lt;html class="ie ie7" &lt;?php language_attributes(); ?&gt;&gt; &lt;![endif]--&gt; &lt;!--[if IE 8]&gt; &lt;html class="ie ie8" &lt;?php language_attributes(); ?&gt;&gt; &lt;![endif]--&gt; &lt;!--[if !(IE 7) | !(IE 8) ]&gt;&lt;!--&gt; &lt;html &lt;?php language_attributes(); ?&gt;&gt; &lt;!--&lt;![endif]--&gt; &lt;head&gt; &lt;meta charset="&lt;?php bloginfo( 'charset' ); ?&gt;" /&gt; &lt;meta name="viewport" content="width=device-width" /&gt; &lt;title&gt;&lt;?php wp_title( '|', true, 'right' ); ?&gt;&lt;/title&gt; &lt;link rel="profile" href="http://gmpg.org/xfn/11" /&gt; &lt;link rel="pingback" href="&lt;?php bloginfo( 'pingback_url' ); ?&gt;" /&gt; &lt;?php // Loads HTML5 JavaScript file to add support for HTML5 elements in older IE versions. ?&gt; &lt;!--[if lt IE 9]&gt; &lt;script src="&lt;?php echo get_template_directory_uri(); ?&gt;/js/html5.js" type="text/javascript"&gt;&lt;/script&gt; &lt;![endif]--&gt; &lt;?php wp_head(); ?&gt; &lt;/head&gt; &lt;body &lt;?php body_class(); ?&gt;&gt; &lt;div id="page" class="hfeed site"&gt; &lt;header id="masthead" class="site-header" role="banner"&gt; &lt;hgroup&gt; &lt;h1 class="site-title"&gt;&lt;a href="&lt;?php echo esc_url( home_url( '/' ) ); ?&gt;" title="&lt;?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?&gt;" rel="home"&gt;&lt;?php bloginfo( 'name' ); ?&gt;&lt;/a&gt;&lt;/h1&gt; &lt;h2 class="site-description"&gt;&lt;?php bloginfo( 'description' ); ?&gt;&lt;/h2&gt; &lt;/hgroup&gt; &lt;nav id="site-navigation" class="main-navigation" role="navigation"&gt; &lt;h3 class="menu-toggle"&gt;&lt;?php _e( 'Menu', 'twentytwelve' ); ?&gt;&lt;/h3&gt; &lt;a class="assistive-text" href="#content" title="&lt;?php esc_attr_e( 'Skip to content', 'twentytwelve' ); ?&gt;"&gt;&lt;?php _e( 'Skip to content', 'twentytwelve' ); ?&gt;&lt;/a&gt; &lt;?php wp_nav_menu( array( 'theme_location' =&gt; 'primary', 'menu_class' =&gt; 'nav-menu' ) ); ?&gt; &lt;/nav&gt;&lt;!-- #site-navigation --&gt; &lt;?php if ( get_header_image() ) : ?&gt; &lt;a href="&lt;?php echo esc_url( home_url( '/' ) ); ?&gt;"&gt;&lt;img src="&lt;?php header_image(); ?&gt;" class="header-image" width="&lt;?php echo get_custom_header()-&gt;width; ?&gt;" height="&lt;?php echo get_custom_header()-&gt;height; ?&gt;" alt="" /&gt;&lt;/a&gt; &lt;?php endif; ?&gt; &lt;/header&gt;&lt;!-- #masthead --&gt; &lt;div id="main" class="wrapper"&gt; </code></pre> <p>This file start with the beginning tag but I can't see the link to the used <strong>style.css</strong> file. Where is it?</p> <p>Tnx</p> <p>Andrea</p> </div>

wordpress function.php无法加载css样式表

<div class="post-text" itemprop="text"> <p>I've tried for hours to make wp_enqueue_style running when load in head part.</p> <p>this is my code</p> <pre><code>function test_script(){ //Add Bootstrap Style wp_enqueue_style('muarif-bootstrap',get_template_directory_uri().'/inc/css/bootstrap.css'); } add_action('wp_enqueue_scripts','test_script'); </code></pre> <p>But when i running my website, it's not load properly.</p> <p>Here is my generated head</p> <pre><code>&lt;head&gt; &lt;title&gt;Muarif Gustiar | Web Developer - User Experience - Digital Marketing&lt;/title&gt; &lt;meta charset="UTF-8"&gt; &lt;meta name="description" content=""&gt; &lt;meta name="viewport" content="width=device-width,initial-scale=1.0"&gt; &lt;meta http-equiv="content-type" content="text/html; charset=UTF-8"&gt; &lt;style type="text/css"&gt;&lt;/style&gt; &lt;/head&gt; </code></pre> <p>What wrong with my code? i follow the instruction to enqueue <a href="http://www.pixafy.com/blog/2013/06/how-to-enqueue-a-custom-stylesheet-via-functions-php-in-wordpress" rel="nofollow">here</a>. Any suggestion?</p> </div>

如何让Wordpress加载我的html和css代码

<div class="post-text" itemprop="text"> <p>So I've been trying to create a homepage for my WP website that would have its own design not based on the theme. I want it to be a simple html and css page and then Wordpress stuff kicks in when a user clicks a link. I don't need header, footer sidebar tags or anything like that, you could say I just want an html/css homepage separate from the Wordpress.</p> <p>I've read about custom templates and tried editing theme functions by adding this:</p> <pre><code>function wpse_enqueue_page_template_styles() { if ( is_page_template( 'customhome.php' ) ) { wp_enqueue_style( 'page-template', get_stylesheet_directory_uri() . '/custom-home.css' ); } } add_action( 'wp_enqueue_scripts', 'wpse_enqueue_page_template_styles' ); </code></pre> <p>but when I create a page with the template it shows me plain html and doesn't load css.</p> <p>I'm quite new to Wordpress theme editing and don't know php that much but adding your own html/css is said to be quite easy in WP.</p> <p>How do I integrate my code into WP so it loads only my html with the correct css?</p> </div>

WordPress子主题不格式化

<div class="post-text" itemprop="text"> <p>I'm aware that people have had similar issues, but reading through questions here on stackoverflow, and on WP Codex, has not helped me to solve this issue. This is the second child theme I've made. The first one worked perfectly. For some reason, even though I did everything the same, this one does not reflect the formatting of the parent theme. My suspicion is that I either need to enqueue multiple .css for this particular theme, or I have an incorrect tag. Hoping that a new set of eyes could find the problem.</p> <p>Here is the style.css for the child theme:</p> <pre><code>/* Theme Name: Kale-child Theme URI: https://panaceats.com/ Author: **** Author URI: https://panaceats.com/ Description: child theme of Kale Template: kale Version: 1.0.0 License: GPLv3 or later License URI: http://www.gnu.org/licenses/gpl-3.0.en.html Text Domain: kale Domain Path: /languages/ Tags: one-column, two-columns, three-columns, right-sidebar, grid-layout, flexible-header, custom-background, custom-colors, custom-header, custom-menu, featured-images,footer-widgets, full-width-template, theme-options, threaded-comments, translation-ready, food-and-drink */ </code></pre> <p>And here is the functions.php for the child theme:</p> <pre><code>&lt;?php function my_theme_enqueue_styles() { $parent_style = 'kale-style'; wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' ); wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( $parent_style ), wp_get_theme()-&gt;get('Version') ); } add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' ); ?&gt; </code></pre> <p>As you can see, I have followed the directions from the <a href="https://codex.wordpress.org/Child_Themes" rel="nofollow noreferrer">WP Codex - CT</a>.</p> <p><a href="http://www.lyrathemes.com/preview/?theme=kale" rel="nofollow noreferrer">This</a> is what the formatting is supposed to look like.</p> <p>UPDATE: I have now got my child theme looking like the parent theme by copy/pasting all the content from the parent style.css to the child. However, doesn't this defeat the purpose of enqueue? If I have the parent and child enqueued correctly, shouldn't the formatting from the parent reflect in the child theme?</p> </div>

在wordpress中动态更改样式表中的url路径

<div class="post-text" itemprop="text"> <p><em>I posted this to the wordpress stack exchange, but I also think its a good idea to post this here</em></p> <p>Hello I found a function that when placed in the functions.php, it injects the entire stylesheet into the head on the website:</p> <pre><code>add_action( 'wp_head', 'internal_css_print' ); function internal_css_print() { echo '&lt;style&gt;'; include_once get_template_directory() . '/style.css'; echo '&lt;/style&gt;'; } </code></pre> <p>It works great, the whole stylesheet goes in the head just fine, but one minor issue is that the urls in the css are broken. For example when the following is in the css file:</p> <pre><code>background: url('images/hero-desktop.jpg'); </code></pre> <p>When the stylesheet is linked normally, this returns <code>http://localhost:8888/wp-content/themes/my-theme/images/hero-desktop.jpg</code>-&gt; works</p> <p>But when the stylesheet is injected in the head it returns: <code>http://localhost:8888/images/hero-desktop.jpg</code> --&gt; doesnt work. The path is broken.</p> <p>To fix this I can do a simple search and replace in the css to change <code>url('</code> to <code>url('/wp-content/themes/my-theme/</code> but there has to be a better way. </p> <p>So I was thinking is there something to add to the function at the top, so before spitting out the whole css file into the head, it dynamically changes the url paths from <code>url(/images/)</code> to <code>/wp-content/themes/my-theme/images/</code>. If this is possible that would be great so its just a one time setup instead of searching and replacing css on an already developed site.</p> <p>Thanks!</p> </div>

在Wordpress中链接样式表

<div class="post-text" itemprop="text"> <p>I am trying to link my stylesheet to another page in Wordpress. The actual Wordpress installation is within a folder, within the actual site. It's set up this way because I only want to use WP for a specific section of the site (it was an afterthought, I know this is isn't necessarily the "correct" way to do things...) </p> <p>I have the front page set up and the styles are all working fine. But when a create a new page and try to use get_header to pull in the styles, they don't work. The browser is looking for a page called styles.css, not a stylesheet. </p> <p>I've tried to use "enqueue" in the functions.php file, but it still won't work. I have a copy of my style sheet in the theme folder and also one inside a css folder. </p> <p>Example of using enqueue for the copy inside the css folder:</p> <pre><code>wp_enqueue_script( 'styles', 'get_stylesheet_directory_uri()' . 'css/styles2.css' ); </code></pre> <p>*I am using get_header in my page template file, (same header as the front page which is working fine), and it is linked this way:</p> <pre><code>&lt;link rel="stylesheet" type="text/css" href="../css/styles2.css"&gt; </code></pre> <p>I'm pretty sure the issue is the "../" but when I substitute <code>echo get_stylesheet_directory_uri().......</code> instead of the ../, it doesn't work as it should.</p> <p>Any help would be great as I'm newer to WP development.</p> <p>Thanks everyone</p> </div>

在php文件wordpress变量访问上使用css样式

<div class="post-text" itemprop="text"> <p>hi guzz i am create wordpress plugin and i want to access php variable on css style i include <code>'style.php'</code> file and i want to access php style variable on this file but how , my php code</p> <pre><code>&lt;?php function my_style_render(){ // mystyle file load wp_enqueue_style('mystyle', MY_PLUGIN_URL."/css/my_style.css"); $color = '#149382'; ob_start(); include MY_PLUGIN_PATH . '/css/style.php'; $custom_css = ob_get_clean(); wp_add_inline_style( 'mystyle', $custom_css ); } ?&gt; //and my style.php file .model_inline { background-color: {$color}; } </code></pre> <p>but color in not apply on <strong>'model_inline'</strong> class ... anyone suggestion ..</p> </div>

在Wordpress网站上发布预加载CSS

<div class="post-text" itemprop="text"> <p>I am having trouble preloading CSS on my WordPress site. I was writing a script to find every JS and CSS script enqueued in the footer, and preload it in the <code>&lt;head&gt;</code>. The code for the JS scripts works fine (when I go to page source on the site, I can see the <code>&lt;link&gt;</code> tags with the preload attribute inside), but the CSS preload link tags aren't showing up.</p> <p>It is very likely I am doing this completely wrong, as I found working code for the JS scripts and then tried to alter it to get it to work for the CSS. For instance, I don't think the version appendage applies to CSS, but I assumed it would still work since it would default to false, right? </p> <p>As a related question, I am having the same issue with webfonts. Google Pageview Insights is telling me to preload webfonts, so I added some php to do that, but when I run pageview insights again, no dice. </p> <p>Here is the code:</p> <p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>add_action('wp_head', function () { global $wp_scripts; global $wp_styles; foreach($wp_scripts-&gt;queue as $handle) { $script = $wp_scripts-&gt;registered[$handle]; //-- Check if script is being enqueued in the footer. if($script-&gt;extra['group'] === 1) { //-- If version is set, append to end of source. $source = $script-&gt;src . ($script-&gt;ver ? "?ver={$script-&gt;ver}" : ""); //-- Spit out the tag. echo "&lt;link rel='preload' href='{$source}' as='script'/&gt; "; } } foreach($wp_styles-&gt;queue as $handle) { $style = $wp_styles-&gt;registered[$handle]; if ($style-&gt;extra['group'] === 1) { $source = $style-&gt;src . ($style-&gt;ver ? "?ver={$style-&gt;ver}" : ""); echo "&lt;link rel='preload' href='{$source}' as='style' onload='this.rel = \"stylesheet\"'/&gt; &lt;noscript&gt;&lt;link rel='stylesheet' href='{$source}'/&gt;&lt;/noscript&gt; "; } } //This is the code to preload webfonts echo "&lt;link rel='preload' href='/wp-content/themes/salient/css/fonts/fontawesome-webfont.woff?v=4.2' as='font' type='font/woff'&gt;"; echo "&lt;link rel='preload' href='/wp-content/themes/salient/css/fonts/fontawesome-webfont.ttf?v=4.2' as='font' type='font/ttf'&gt;"; }, 1);</code></pre> </div> </div> </div>

来自(内部)wordpress仪表板的自定义CSS样式

<div class="post-text" itemprop="text"> <p>I am looking to edit the css styles from inside the Dashboard inside of wordpress <strong><em>and NOT have to edit the php files if possible.</em></strong></p> <p>I know it is possible to edit at least some of the properties so my hope is I can edit all of them right within the dashboard.</p> <p><strong>MORE SPECIFICALLY</strong> How can I change the css states of links and submenus of a custom class? For example the a:active, a:hover, a:link etc... and ALL OF THE SUB-MENUS to custom css as well?</p> <p>I have included these pictures to show you what I am trying to do and the present results.</p> <p><strong>MY CUSTOM MENU INSIDE OF WORDPRESS</strong></p> <p><img src="https://i.stack.imgur.com/7y6og.png" alt="enter image description here"> </p> <p><strong>CUSTOM CSS INSIDE OF WORDPRESS</strong> <img src="https://i.stack.imgur.com/MQ7Bc.png" alt="enter image description here"></p> <p><strong>THE RESULTS</strong></p> <p><img src="https://i.stack.imgur.com/zYZTG.png" alt="enter image description here"></p> </div>

有条件地在Wordpress中打印CSS样式

<div class="post-text" itemprop="text"> <p>I am working on a Wordpress theme and want to give the option to choose between a boxed layout and a full width layout.</p> <p>For this purpose I created a variable in my header.php:</p> <pre><code>&lt;head&gt; &lt;?php $isBoxedLayout = true; ?&gt; ... &lt;/head&gt; </code></pre> <p>Down in the body I am asking if the variable is set:</p> <pre><code>&lt;?php if($isBoxedLayout) { echo '&lt;div id="boxed"&gt;'; } ?&gt; ... &lt;?php if($isBoxedLayout) { echo '&lt;/div&gt;'; } ?&gt; </code></pre> <p>This works fine so far. But now I also want to change some css styles if this variable is set. My problem is that I am not so good in PHP yet so my solution would be something like this:</p> <pre><code>&lt;head&gt; &lt;?php $isBoxedLayout = true; ?&gt; ... if ($isBoxedLayout) { echo '&lt;style type="text/css"&gt;'; echo '#container {width:999px;}'; echo '&lt;/style&gt;'; } &lt;/head&gt; </code></pre> <p>But I think this is not good programming because my header.php file would soon be full of code and confusing if I would add some other options. So logically I should create a variable or an array maybe in the functions.php file and outsource my code like this:</p> <pre><code>$isBoxedLayout = true; if ($isBoxedLayout) { function boxed_css_styles() { echo '&lt;style type="text/css"&gt;'; echo '#container {width:999px;}'; echo '&lt;/style&gt;'; } } </code></pre> <p>Is my thinking right? And if so how would I access the functions I create in my index.php or header.php or whatever. Or would it work to print the styles in the functions.php?</p> <p>best regards</p> </div>

在WordPress中使用PHP更改CSS样式

<div class="post-text" itemprop="text"> <p>I'm somewhat new to PHP and WordPress and I'm trying style a menu plugin (their support is busy) based on what page the user is on. <br><br> What I want is for the background and other styles to change if it isn't on the front page.</p> <p>I've tested the CSS in inspect element so the selectors are correct, but I don't really know how to implement this in a clean and effective way. <br><br> The messy way would be to create another two menus (because top_navigation and main_menu are separate so 4 total) style those in their plugin settings and replace the two menus on the front page with two other ones when not on the front page using php. So if I need to make a change the menu's items I'd have to do it for two or four times which to me is stupid.</p> <hr> <p>So far I've come up with creating a PHP variant of the style sheet and rewriting the URL to redirect from .css to .php however I don't really have a firm grasp on how I would do this from the root directory's .htaccess as the location of the two style sheets are far from it.</p> <p>Location of style sheets:<code>/wp-content/plugins/hmenu/_frontend_files/_menu_5/_css</code> <br> Name of style sheets: <code>hero_menu_styles.css</code> and <code>hero_menu_styles.php</code> <br> PHP Style sheet:</p> <pre><code>&lt;?php header('Content-type: text/css; charset: UTF-8'); ?&gt; /* Normal CSS Here */ &lt;?php if(!is_front_page()) { echo "#hmenu_load_5 .hmenu_main_holder {background-color: #67b7e1;}" } ?&gt; </code></pre> <p>.htaccess: <br> I am almost 100% sure there is something wrong with this. <br> I have no idea what though.</p> <pre><code># BEGIN WordPress &lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteBase "/wp-content/plugins/hmenu/_frontend_files/_menu_5/_css/" RewriteRule ^hero\_menu\_styles\.css$ hero\_menu\_styles\.php [L] &lt;/IfModule&gt; &lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] &lt;/IfModule&gt; # END WordPress </code></pre> <hr> <p>So I have a bunch of questions.</p> <ol> <li> Does echo work the way that I'm currently writing it assuming that it is in a stylesheet.php rather than a stylesheet.css? </li> <li> What if I were to reference an additional stylesheet.php on all my pages and just put it in there rather than rewriting my URLs? Is there a way to make sure it would override the other stylesheets? </li> <li> Can I have multiple .htaccess files <br> (for example in /wp-content/plugins/hmenu/_frontend_files/_menu_5/_css) <br> so I don't have to bother with long RewriteBase headaches? </li> <li> Am I correct in that I cannot just stick this code+css into my WordPress theme's header.php or functions.php? </li> <li> Do I need to require('/wp-load.php'); or load some WordPress functions (no idea what other than wp-load though) on my .php stylesheet if I wanted to use is_front_page()? </li> </ol> </div>

如何在样式表Wordpress中链接背景图像?

<div class="post-text" itemprop="text"> <pre><code>.jumbotron { margin-bottom: 0px; background-image: url(../img/desktop-urania.jpg); min-height: 600px; background-attachment: fixed; background-position: center; background-repeat: no-repeat; background-size: cover; } </code></pre> <p>This is the working CSS in HTML, but i am trying to convert HTML to WordPress, while converting I link my stylesheet in function.php <strong>(function urania_script_enqueue() { wp_enqueue_style('customstyle', get_template_directory_uri() . '/css/urania.css', array( '$handle', '$src', '$deps', '$ver', '$media'), '1.0.0', 'all');)</strong></p> <p>but image is not loading ... </p> <p>Theme Name URANIA:: -&gt; Css-&gt; urania.css (Stylesheet) Theme Name URANIA:: -&gt; img -&gt; desktop-urania.jpg (image)</p> <p>Please Help</p> </div>

wordpress主题背景图片失效,无法显示,所有主题都不行,同时后台部分css无法显示

下图是首页,无法显示主题背景图片 ![图片说明](https://img-ask.csdn.net/upload/201701/30/1485758051_513681.png) 按照道理应该是下面第一张图片的样子 ![图片说明](https://img-ask.csdn.net/upload/201701/30/1485758112_638966.png) 同时在后台的部分css样式无法显示 ![图片说明](https://img-ask.csdn.net/upload/201701/30/1485758172_61122.png) 这是什么原因,跪求大佬解释

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

Java基础知识面试题(2020最新版)

文章目录Java概述何为编程什么是Javajdk1.5之后的三大版本JVM、JRE和JDK的关系什么是跨平台性?原理是什么Java语言有哪些特点什么是字节码?采用字节码的最大好处是什么什么是Java程序的主类?应用程序和小程序的主类有何不同?Java应用程序与小程序之间有那些差别?Java和C++的区别Oracle JDK 和 OpenJDK 的对比基础语法数据类型Java有哪些数据类型switc...

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

Intellij IDEA 实用插件安利

1. 前言从2020 年 JVM 生态报告解读 可以看出Intellij IDEA 目前已经稳坐 Java IDE 头把交椅。而且统计得出付费用户已经超过了八成(国外统计)。IDEA 的...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

魂迁光刻,梦绕芯片,中芯国际终获ASML大型光刻机

据羊城晚报报道,近日中芯国际从荷兰进口的一台大型光刻机,顺利通过深圳出口加工区场站两道闸口进入厂区,中芯国际发表公告称该光刻机并非此前盛传的EUV光刻机,主要用于企业复工复产后的生产线扩容。 我们知道EUV主要用于7nm及以下制程的芯片制造,光刻机作为集成电路制造中最关键的设备,对芯片制作工艺有着决定性的影响,被誉为“超精密制造技术皇冠上的明珠”,根据之前中芯国际的公报,目...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

2020阿里全球数学大赛:3万名高手、4道题、2天2夜未交卷

阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

为什么你不想学习?只想玩?人是如何一步一步废掉的

不知道是不是只有我这样子,还是你们也有过类似的经历。 上学的时候总有很多光辉历史,学年名列前茅,或者单科目大佬,但是虽然慢慢地长大了,你开始懈怠了,开始废掉了。。。 什么?你说不知道具体的情况是怎么样的? 我来告诉你: 你常常潜意识里或者心理觉得,自己真正的生活或者奋斗还没有开始。总是幻想着自己还拥有大把时间,还有无限的可能,自己还能逆风翻盘,只不是自己还没开始罢了,自己以后肯定会变得特别厉害...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

Python爬虫,高清美图我全都要(彼岸桌面壁纸)

爬取彼岸桌面网站较为简单,用到了requests、lxml、Beautiful Soup4

差点跪了...

最近微信又搞出了一个大利器,甚至都上了热搜,当然消息最敏捷的自媒体人,纷纷都开通了自己的视频号。01 视频号是什么呢?视频号是微信体系内的短视频,它不同...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

Vue回炉重造之router路由(更新中)

你好,我是Vam的金豆之路,可以叫我豆哥。2019年年度博客之星、技术领域博客专家。主要领域:前端开发。我的微信是 maomin9761,有什么疑问可以加我哦,自己创建了一个微信技术交流群,可以加我邀请你一起交流学习。最后自己也创建了一个微信公众号,里面的文章是我自己精挑细选的文章,主要介绍各种IT新技术。欢迎关注哦,微信搜索:臻美IT,等你来。 欢迎阅读本博文,本博文主要讲述【】,文字通...

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

Java岗开发3年,公司临时抽查算法,离职后这几题我记一辈子

前几天我们公司做了一件蠢事,非常非常愚蠢的事情。我原以为从学校出来之后,除了找工作有测试外,不会有任何与考试有关的事儿。 但是,天有不测风云,公司技术总监、人事总监两位大佬突然降临到我们事业线,叫上我老大,给我们组织了一场别开生面的“考试”。 那是一个风和日丽的下午,我翘着二郎腿,左手端着一杯卡布奇诺,右手抓着我的罗技鼠标,滚动着轮轴,穿梭在头条热点之间。 “淡黄的长裙~蓬松的头发...

大胆预测下未来5年的Web开发

在2019年的ReactiveConf 上,《Elm in Action》的作者Richard Feldman对未来5年Web开发的发展做了预测,很有意思,分享给大家。如果你有机会从头...

立即提问
相关内容推荐