admin管理员组文章数量:1122832
EDIT: I've found out that by using Advanced Custom Fields I can edit multiple fields on a page. Why WP doesn't have this feature by default I'll never know.
This is the kind of ability I was looking for that PerchCMS has by default.
Thanks for your answers.
I'm new to writing websites using Wordpress as a CMS, and in the past I've used a CMS called PerchCMS which allows me to add extra multiple sections by using the php tag of:
<?php perch_content('InformationTitle');?>
<?php perch_content('Information');?>
<?php perch_content('AboutTitle');?>
<?php perch_content('AboutContent');?>
With Wordpress I really don't understand how to add multiple sections in this way, I trawled the Internet for answers, but there appear to be no answers anywhere else.
Part of my code is as follows:
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<img src="<?php bloginfo('template_directory'); ?>/assets/img/logo.png" class="fg3 logo" alt="Logo" />
<div id='services'>
<p>
<?php the_content('services'); ?>
</p>
</div>
<div id='about'>
<p>
<?php the_content('about'); ?>
</p>
</div>
With this method, all the content I write gets repeated.
What am I doing wrong? I understand that the loop is there to loop through the posts on the page, and I've seen mention of plugins such to achieve this, but surely Wordpress should offer this by default? There are many many sites that have different sections that need to be edited independently.
Any help is greatly appreciated.
EDIT: I've found out that by using Advanced Custom Fields I can edit multiple fields on a page. Why WP doesn't have this feature by default I'll never know.
This is the kind of ability I was looking for that PerchCMS has by default.
Thanks for your answers.
I'm new to writing websites using Wordpress as a CMS, and in the past I've used a CMS called PerchCMS which allows me to add extra multiple sections by using the php tag of:
<?php perch_content('InformationTitle');?>
<?php perch_content('Information');?>
<?php perch_content('AboutTitle');?>
<?php perch_content('AboutContent');?>
With Wordpress I really don't understand how to add multiple sections in this way, I trawled the Internet for answers, but there appear to be no answers anywhere else.
Part of my code is as follows:
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<img src="<?php bloginfo('template_directory'); ?>/assets/img/logo.png" class="fg3 logo" alt="Logo" />
<div id='services'>
<p>
<?php the_content('services'); ?>
</p>
</div>
<div id='about'>
<p>
<?php the_content('about'); ?>
</p>
</div>
With this method, all the content I write gets repeated.
What am I doing wrong? I understand that the loop is there to loop through the posts on the page, and I've seen mention of plugins such to achieve this, but surely Wordpress should offer this by default? There are many many sites that have different sections that need to be edited independently.
Any help is greatly appreciated.
Share Improve this question edited May 3, 2017 at 8:41 fuxia♦ 107k38 gold badges255 silver badges459 bronze badges asked Aug 7, 2013 at 11:29 JoshJosh 731 gold badge1 silver badge11 bronze badges 7 | Show 2 more comments1 Answer
Reset to default 0you can't pass nothing inside the_content();
except a "read more".
To achieve what you need it could be done this way;
<?php get_header(); ?> // getting the header
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> // the loop stuff
<?php
// PAGE 1
$page_id = 8454; // id of the page you need to pull out the content of
$page_data = get_page( $page_id ); // getting the data from the page
$content = apply_filters('the_content', $page_data->post_content); // filtering
echo $content; // outputting the content
// PAGE 2
$page_id = 8456;
$page_data = get_page( $page_id );
$content = apply_filters('the_content', $page_data->post_content);
echo $content;
// PAGE 3
$page_id = 8458;
$page_data = get_page( $page_id );
$content = apply_filters('the_content', $page_data->post_content);
echo $content;
?>
<?php endwhile; endif; ?> <?php // ending while and if ?>
<?php // get_sidebar(); ?> <?php // get the side bar if you want ?>
<?php get_footer(); ?> <?php // the footer ?>
• Now create a page (Pages > Add New) with the info you want to output and save it.
• Find out the ID of the page (look at the URL of the page you just saved) it's the number you see after post.php?=
http://www.yoursite.com/wp-admin/post.php?post=8458&action=edit
• Now copy that number and place it $page_id = HERE
------- EDITS -------
for me that's the best way... you have lots of pages but at least they are organized.
BUT!!! if you wish, You can have everything in 1 single page, in admin area, and output only the content of that page. In wordpress you can use HTML tags in pages, so on that single page you can have multiple <div>s <p>s <h1>s <img>s
with the content you want.
index.php
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php
$page_id = 8454;
$page_data = get_page( $page_id );
$content = apply_filters('the_content', $page_data->post_content);
echo $content;
?>
<?php endwhile; endif; ?> <?php // ending while and if ?>
<?php // get_sidebar(); ?> <?php // get the side bar if you want ?>
<?php get_footer(); ?> <?php // the footer ?>
in admin are create a page and put all your content inside it:
<h1>Services</h1>
<div id="services">CONTENT OF SERVICES</div>
<h1>About</h1>
<div id="about">CONTENT OF About</div>
<h1>Images</h1>
<div id="images">
<img src="" alt="" />
<p>Some description</p>
</div>
本文标签: cmsMultiple editable content on page
版权声明:本文标题:cms - Multiple editable content on page 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736295717a1929629.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
wp_editor()
. I don't have time to write a complete answer right now, but I'll try to come up with something later today, if no one else has. – Pat J Commented Aug 7, 2013 at 12:45get_post_meta()
for display. Essentially, the post's content would be your first section, and then the meta boxes would contain your additional fields. – Pat J Commented Aug 7, 2013 at 13:07