我必须将帖子内容放入标签中<head>.我正在尝试将此代码放入我主题的header.php文件中:
if(is_single()){
$stringa = the_content();
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
我能怎么做?谢谢
我在我的系统上安装了wordpress.我使用的是20个主题,在主题目录中有style.css文件.在那个文件中我试过了
body {
background-color: red;
}
Run Code Online (Sandbox Code Playgroud)
但没有任何反应,无论style.css有什么变化,它都不会反映在浏览器中.请帮忙.
我想在首页的帖子中添加缩略图.但不知道该怎么做.我的主题不支持custom_field.其中一个类别的代码是我粘贴在这里.......
<div class="featured">
<h2>HEADLINES</h2>
<!--This is where the thumbnails are found for the homepage bottom section - note the custom field name for this image is "thumbnail". Recommended image size is 70x70, as the stylesheet is written for this size.-->
<?php $recent = new WP_Query("cat=3&showposts=3");
while($recent->have_posts()) : $recent->the_post();?>
<?php the_post_thumbnail(); ?>
<?php if( get_post_meta($post->ID, "thumbnail", true) ): ?>
<a href="<?php the_post_thumbnail() ?>" rel="bookmark"><imgstyle="float:left;margin:0px 10px 0px 0px;" src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" alt="alt text" /></a>
<?php else: ?>
<a href="<?php …Run Code Online (Sandbox Code Playgroud) 我正在尝试编辑在您点击添加评论按钮(来自管理员面板)时显示的错误消息,而不键入注释.

这是处理此错误消息的wp_ajax_replyto_comment函数(来自wp-admin/includes/ajax-actions.php).
function wp_ajax_replyto_comment( $action ) {
global $wp_list_table, $wpdb;
if ( empty( $action ) )
$action = 'replyto-comment';
check_ajax_referer( $action, '_ajax_nonce-replyto-comment' );
set_current_screen( 'edit-comments' );
$comment_post_ID = (int) $_POST['comment_post_ID'];
if ( !current_user_can( 'edit_post', $comment_post_ID ) )
wp_die( -1 );
$status = $wpdb->get_var( $wpdb->prepare("SELECT post_status FROM $wpdb->posts WHERE ID = %d", $comment_post_ID) );
if ( empty($status) )
wp_die( 1 );
elseif ( in_array($status, array('draft', 'pending', 'trash') ) )
wp_die( __('ERROR: you are …Run Code Online (Sandbox Code Playgroud) 我的代码:
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="posts" id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h2>
<?php the_title(); ?>
</h2>
<div class="entry">
<?php the_content();?>
</div>
</div><!--post end-->
<?php endwhile; ?>
<?php else : ?>
<h3>no content</h3>
<?php endif; ?>
Run Code Online (Sandbox Code Playgroud)
我将代码放入我自定义的wordpress主题文件single.php中.为什么它不能输出帖子内容,它可以输出帖子标题.谢谢.
有人能够如此迅速地帮助我解决我花了几个小时和几个小时的问题,我希望我会幸运,有人可以指出我在这个问题上的正确方向.
我没有看到其他人在这里遇到我的问题 - 我不熟悉WP模板而不是普通的旧HTML/CSS/JS.
基本上 - 在我们做过的网站(www.opted.org)上购买了WP主题 - 我无法通过移动版可折叠菜单来停止将页面加载默认为主菜单中的最后一项.
因此,不是有意义的东西 - 比如关于ASCO,或者甚至能够添加"选择页面" - 下拉菜单显示" - 过去的问题"
我不在乎我是如何修复它的,但客户端只是不希望该页面成为默认页面.我尝试在末尾添加一个名为"选择页面"的额外菜单项,其中包含href ='#'并使用CSS将其隐藏在480px以上的屏幕上 - 但无论我如何尝试引用它,我都无法使其工作它.
我觉得这应该很容易 - 但我不知道在许多WP文件中将所选LI设置在何处.
谢谢!!
我是WordPress的新手,我对如何将CSS文件链接到WP主题有以下疑问.
例如,这是TwentyTwelve预安装模板的header.php文件:
<?php
/**
* The Header template for our theme
*
* Displays all of the <head> section and everything up till <div id="main">
*
* @package WordPress
* @subpackage Twenty_Twelve
* @since Twenty Twelve 1.0
*/
?><!DOCTYPE html>
<!--[if IE 7]>
<html class="ie ie7" <?php language_attributes(); ?>>
<![endif]-->
<!--[if IE 8]>
<html class="ie ie8" <?php language_attributes(); ?>>
<![endif]-->
<!--[if !(IE 7) | !(IE 8) ]><!-->
<html <?php language_attributes(); ?>>
<!--<![endif]-->
<head>
<meta charset="<?php bloginfo( …Run Code Online (Sandbox Code Playgroud) css php wordpress wordpress-theming content-management-system
我创建包含HTML元素,如WordPress的网页<div>和<ul>如
<div id="main" class="large-12 medium-12 columns clearfix" role="main">
<h2 class="press-list-header">Articles</h2>
<ul class="press-list">
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
我想在这些HTML元素中放置短代码,如下所示:
<div id="main" class="large-12 medium-12 columns clearfix" role="main">
<h2 class="press-list-header">Articles</h2>
<ul class="press-list">
[picture image="http://example.com/image1.jpg" thumbnail="http://example.com/image1-thumbnail.jpg"]
[picture image="http://example.com/image2.jpg" thumbnail="http://example.com/image2-thumbnail.jpg"]
[picture image="http://example.com/image3.jpg" thumbnail="http://example.com/image3-thumbnail.jpg"]
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
当我这样做时,短代码只在渲染页面上显示为常规文本.如果我只是将短代码放在HTML元素之外,那么它们就可以正常地将预期内容呈现在页面上.
如何获取我的短代码以将其内容包装在HTML元素中?
我应该更具描述性.我希望我的客户能够轻松地在TinyMCE编辑器中输入简短的代码来获取页面和帖子.我不希望他们不得不处理php或html代码.他们无法访问这些.php模板文件,因为他们不是开发人员.我已经得到了短代码,只用于帖子而不是页面.我相信这样做的原因是我使用的模板调用custom-page.php了我的所有页面,如下所示:
<?php /* Template Name: Custom */ ?>
<?php get_header(); ?>
<div id="content">
<div id="inner-content" class="row clearfix">
<?php the_post(); global $post; echo $post->post_content; ?>
</div> <!-- end #inner-content -->
</div> <!-- end …Run Code Online (Sandbox Code Playgroud) 我正在开发我自己的Wordpress主题,我在尝试获取自定义帖子("事件")时遇到了我的functions.php文件" 调用未定义函数WP_Query() ".
我已经尝试添加include('wp-load.php'),但没有改变任何东西.
有没有人有同样的问题?已经做了一些研究,但没有找到解决我问题的任何东西.
这是我的简单代码:
$argsEvents = array('post_type' => 'event', 'posts_per_page' => '-1');
$result = WP_Query( $argsEvents );
if ( $result->have_posts() ) {
echo '<ul>';
while ( $result->have_posts() ) {
$result->the_post();
echo '<li>' . get_the_title() . '</li>';
}
echo '</ul>';
wp_reset_postdata();
} else echo "No data";
Run Code Online (Sandbox Code Playgroud)
非常感谢你的帮助!
阿娇
当您有很多选项时,ACF后端/管理面板会变得非常混乱.我看到你可以在哪里更改宽度百分比并将自己的类添加到自定义字段中,但是如何设置这些类的样式?只是将这些类名添加到style.css不起作用!