Why content in my page can't display? - wordpress

I edit a new page, here is the content.
Publish and view it.
Why is nothing displayed?
The theme is "twentyfourteen".
sudo cat /var/www/html/wp/wp-content/themes/twentyfourteen-child/page.php
<?php /* Template Name: Custom Front Page */ ?>
<?php
/**
* The template for displaying all pages
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages and that
* other ‘pages’ on your WordPress site will use a different template.
*
* #package WordPress
* #subpackage Twenty_Fourteen
* #since Twenty Fourteen 1.0
*/
get_header(); ?>
<div id=”main-content” class=”main-content”>
<div id=”primary” class=”content-area”>
<div id=”content” class=”site-content” role=”main”>
<p>it is a test</p>
</div><!– #content –>
</div><!– #primary –>
<?php get_sidebar( ‘content’ ); ?>
</div><!– #main-content –>
<?php
Why are all the double quotation marks ” instead of ", and single quotation marks are ‘ instead of '?
How do I get my page to display?
Are the quotation marks in the right format?

You don't print the content on the site. The best way do to this is to do it with the WordPress loop. So the code should look something like this:
<?php </* Template Name: Custom Front Page */ ?>
<?php get_header(); ?>
<div id="main-content" class="main-content">
<div id=”primary” class=”content-area”>
<div id="content" class="site-content" role="main">
<?php if(have_posts): while(have_posts): the_post(); ?>
<h1><?php the_title(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
</div>
</div>
<?php get_sidebar( 'content' ); ?>
</div>
<?php get_footer(); ?>
No it should be " and '

Related

Change Woocommerce pagination permalinks

My Woocommerce Shop uses pretty permalinks but I want to disable it for pagination.
When I visit a Category page and manually add the parameter „?paged=2“ for example the page does not redirect me to the permalink version.
But as of now the links are generated like „/page/2“.
How can I achieve that the parameter version is used on the Category page instead of „/page/2“?
Code for the Archive Pages:
<?php
get_header();
do_action( 'shoptimizer_page_start' );
?>
<div id="primary" class="content-area">
<main id="main" class="site-main">
<?php while ( have_posts() ) : the_post();
do_action( 'shoptimizer_page_before' );
get_template_part( 'content', 'page' );
/**
* Functions hooked in to shoptimizer_page_after action
*
* #hooked shoptimizer_display_comments - 10
*/
do_action( 'shoptimizer_page_after' );
endwhile; // End of the loop. ?>
</main><!-- #main -->
</div><!-- #primary -->
<div id="secondary" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'sidebar-1' ); ?>
</div><!-- #secondary -->
<?php
get_footer();
Are you editing via actual PHP? If so, I'd recommend woo_pagination to control that.
Woo_pagination documenation

Create page from a template with customized body

Created a page template named page-person.php
<?php
/**
* Template Name: Person Page
* The template for displaying all pages.
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages
* and that other 'pages' on your WordPress site may use a
* different template.
*
* #link https://codex.wordpress.org/Template_Hierarchy
*
* #package mentorme
*/
get_header(); ?>
<div class="personality">
<!-- dynamic content -->
<?php the_content(); ?>
</div>
<?php get_footer(); ?>
Now I have added some test content, while creating the page from Template 'Person Page' like this
but on page /dr-xyz its not showing text 'Testing' anywhere!
You could use the_content to display your content and the_title() to display your post title. Try the following code
<?php get_header(); ?>
<div class="personality">
<?php if (have_posts()) :
while (have_posts()) : the_post(); ?>
<?php the_title(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php endif; ?>
</div>
<?php get_footer(); ?>
Try this
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
the_content();
} // end while
} // end if

Using Wordpress conditional is_page

I need help with using Wordpress conditional. The below code is the actual code I'm having problems with.
The goal is to check if the page is "bb_press" and if it is, load another template called "archive-forum".
If it's not, then continue using current template.
I tried defining if is_bbpress in the beginning, but I'm not doing something right. Perhaps the ending is the problem..
Help appreciated
<?php
if ( is_bbpress() ) {
get_template_part('archive-forum') {
else {
<--- Continue with the current template code --->
}
<?php endif;?>
<?php get_footer(); ?>
After this, I'm getting a blank page with nothing loaded.
EDIT: This is the orignal template I'm trying to modify. Without your suggestions. Tried them, but I'm doing something wrong. What am I missing here? Am I placing the "if" in the wrong place? Thank you all for your help so far.
<?php
/**
* Directory archive page
*
**/
get_header(); //Header Portion
$tmpdata = get_option('templatic_settings');
global $posts,$htmlvar_name;
do_action('after_event_header');
/* Left content side bar for all pages */
global $htmlvar_name;
if(function_exists('tmpl_get_category_list_customfields')){
$htmlvar_name = tmpl_get_category_list_customfields(CUSTOM_POST_TYPE_EVENT);
}else{
global $htmlvar_name;
}
if (!is_active_sidebar( 'tmpl_listings_left_content') ){
$class="content-middle";
}else{
$class="";
}
/* Here we use for Show left content sidebar , it can be use for many other purpose too */
do_action('tmpl_all_pages_left_content');
?>
<div class="content-sidebar <?php echo $class; ?>">
<script type="text/javascript">
var category_map = '<?php echo $tmpdata['category_map'];?>';
<?php if($_COOKIE['display_view']=='event_map' && $tmpdata['category_map']=='yes'):?>
jQuery(function() {
jQuery('#listpagi').hide();
});
<?php endif;?>
</script>
<!--taxonomy sidebar -->
<!--end taxonomy sidebar -->
<div class="page-head">
<?php
/* back page link */
tmpl_back_link();
do_action('after_directory_header'); /*do action for display the breadcrumb in between header and container. */
do_action('directory_before_container_breadcrumb');
?>
</div>
<?php
if ( is_active_sidebar('listingcategory_listing_above_content') ) : ?>
<div class="filters">
<div id="sidebar-primary" class="sidebar">
<?php dynamic_sidebar('listingcategory_listing_above_content'); ?>
</div>
</div>
<?php endif; ?>
<div class="view_type_wrap">
<?php /*do action to display the breadcrumb inside the container. */
/* Archive page title */
do_action('directory_before_archive_title'); ?>
<h1 class="loop-title">
<?php echo ucfirst(apply_filters('tevolution_archive_page_title','Listing'));?>
</h1>
<?php
if($archive_description[CUSTOM_POST_TYPE_LISTING]['description'] !=''){
?>
<div class="archive-meta"><?php echo $archive_description[CUSTOM_POST_TYPE_LISTING]['description']; ?></div>
<?php
}
do_action('directory_after_archive_title');
do_action('directory_before_loop_archive');
?>
</div>
<div id="content" class="contentarea large-9 small-12 columns <?php directory_class();?>">
<!--Start loop archive page-->
<div id="loop_listing_taxonomy" class="search_result_listing <?php if($tmpdata['default_page_view']=="gridview"){echo 'grid';}else{echo 'list';}?>" <?php if( is_plugin_active('Tevolution-Directory/directory.php') && $tmpdata['default_page_view']=="mapview"){ echo 'style="display: none;"';}?>>
<?php if (have_posts()) :
while (have_posts()) : the_post();
do_action('directory_before_post_loop');?>
<div class="post <?php templ_post_class();?>" >
<?php
/* Hook to display before image */
do_action('tmpl_before_category_page_image');
/* Hook to Display Listing Image */
do_action('directory_category_page_image');
/* Hook to Display After Image */
do_action('tmpl_after_category_page_image');
/* Before Entry Div */
do_action('directory_before_post_entry');?>
<!-- Entry Start -->
<div class="entry">
<?php /* do action for before the post title.*/
do_action('directory_before_post_title'); ?>
<div class="listing-wrapper">
<!-- Entry title start -->
<div class="entry-title">
<?php do_action('templ_post_title'); /* do action for display the single post title */?>
</div>
<?php do_action('directory_after_post_title'); /* do action for after the post title.*/?>
<!-- Entry title end -->
<!-- Entry details start -->
<div class="entry-details">
<?php /* Hook to get Entry details - Like address,phone number or any static field */
do_action('listing_post_info'); ?>
</div>
<!-- Entry details end -->
</div>
<!--Start Post Content -->
<?php /* Hook for before post content . */
do_action('directory_before_post_content');
/* Hook to display post content . */
do_action('templ_taxonomy_content');
/* Hook for after the post content. */
do_action('directory_after_post_content');
?>
<!-- End Post Content -->
<?php
/* Hook for before listing categories */
do_action('directory_before_taxonomies');
/* Display listing categories */
do_action('templ_the_taxonomies');
/* Hook to display the listing comments, add to favorite and pinpoint */
do_action('directory_after_taxonomies');?>
</div>
<!-- Entry End -->
<?php do_action('directory_after_post_entry');?>
</div>
<?php do_action('directory_after_post_loop');
endwhile;
wp_reset_query();
else:?>
<p class='nodata_msg'><?php _e( 'Apologies, but no results were found for the requested archive.', 'templatic' ); ?></p>
<?php endif;
if($wp_query->max_num_pages !=1):?>
<div id="listpagi">
<div class="pagination pagination-position">
<?php if(function_exists('pagenavi_plugin')) { pagenavi_plugin(); } ?>
</div>
</div>
<?php endif;?>
</div>
<!--End loop archive page -->
</div>
</div>
<?php get_footer(); ?>
This is correct code for your condition and will work fine. You have to close the brace for the condition. Check this for condition reference click here
<?php
if ( is_bbpress() ) {
get_template_part('archive-forum');
} else {
// continue with the current template code
}
get_footer();
?>
If you are using brackets, you do not need to use endif; This whole endif; and opening <?php and closing ?> in every row is very ugly. <!-- not valid in PHP code. And you need to add ; after get_template_part('archive-forum');
<?php
if ( is_bbpress() ) {
get_template_part('archive-forum');
} else {
//Continue with the current template code
}
get_footer();
?>
<!-- More none php code here. If there are no more php code, you can leave ?> -->

Woo-commerce shop page removes custom DIVs

I am making a custom theme based on twentytwelve. I am facing a problem regarding woocommerce shop page. I have a page template that work fine. However, when I activate woocommerce plugin and show the shop base page (using my custom page template) it removes all my custom divs and other custom contents. I have followed woocommerce documentation, using both woocommerce.php and action hooks. But it did not produce any result. Here is my code for the page template.
<?php
/**
* Template Name: Front Page Template
*
* Description: A page template that provides a key component of WordPress as a CMS
* by meeting the need for a carefully crafted introductory page. The front page template
* in Twenty Twelve consists of a page content area for adding text, images, video --
* anything you’d like -- followed by front-page-only widgets in one or two columns.
*
* #package WordPress
* #subpackage Twenty_Twelve
* #since Twenty Twelve 1.0
*/
get_header(); ?>
<div id="primary" class="site-content">
<div id="content" role="main">
<div class="rotator">
<ul id="rotmenu">
<?php
$recentposts=get_pages('number=5');
// echo $recentposts;
$ii=0;
if ($recentposts) {
$ii=0;
//foreach($recentposts as $page) {
//setup_postdata($page);
for ($ii=1;$ii<=5;$ii=$ii+1){
//$ii=$ii+1;
$title='r_slideshow_0'.$ii.'_title';
$image='r_slideshow_0'.$ii.'_uploader';
$details='e_slideshow_0'.$ii.'_textarea';
$link='r_slideshow_0'.$ii.'_link';
// echo $page;
// echo $title;
//echo $image;
//echo $details;
//echo of_get_option($image, 'no entry');
?>
<li>
<?php echo of_get_option($title, 'no entry');/*echo $page->post_title;*/ ?>
<div style="display:none;">
<div class="info_image"><?php echo of_get_option($image, 'no entry');?></div>
<div class="info_heading"><?php echo of_get_option($title, 'no entry'); ?></div>
<div class="info_description">
<?php echo of_get_option($details, 'no entry'); ?>
Read Details >><br/>
</div>
</div>
</li>
<?php
//$ii=$ii+1;
}
}
?>
</ul>
<div id="rot1">
<img src="" width="100%" height="300" class="bg" alt=""/>
<div class="heading">
<h1></h1>
</div>
<div class="description">
<p></p>
</div>
</div>
</div>
<!--#rotator on front static page-->
<?php
if(of_get_option('boxchoice_radio', '0' )){
?>
<!--box content-->
<div class="section_front_page group_front_page">
<div class="col_front_page span_1_of_3">
<img src="<?php echo of_get_option('frontpage_boximage_01' ); ?>"style=" ">
<?php if(of_get_option('frontpage_textarea_01' ) && of_get_option('frontpage_textarea_01' )!='Default Text')
{
?>
<?php echo of_get_option('frontpage_textarea_01' ); ?>
<?php } ?>
<br/>
<?php if(of_get_option('frontpage_linkarea_01' ) && of_get_option('frontpage_linkarea_01' )!='Default')
{
?>
Read More >>
<?php } ?>
</div>
<div class="col_front_page span_1_of_3">
<img src="<?php echo of_get_option('frontpage_boximage_02' ); ?>" style="">
<?php if(of_get_option('frontpage_textarea_02' ) && of_get_option('frontpage_textarea_02' )!='Default Text')
{
?>
<p>
<?php echo of_get_option('frontpage_textarea_02' ); ?>
</p>
<?php } ?>
<br/>
<?php if(of_get_option('frontpage_linkarea_02' ) && of_get_option('frontpage_linkarea_02' )!='Default')
{
?>
Read More >>
<?php } ?>
</div>
<div class="col_front_page span_1_of_3">
<img src="<?php echo of_get_option('frontpage_boximage_03' ); ?>"style=" float:right; width:100%;" >
<br/>
<?php if(of_get_option('frontpage_textarea_03' ) && of_get_option('frontpage_textarea_03' )!='Default Text')
{
?>
<?php echo of_get_option('frontpage_textarea_03' ); ?>
<?php } ?>
<?php if(of_get_option('frontpage_linkarea_03' ) && of_get_option('frontpage_linkarea_03' )!='Default')
{
?>
Read More >>
<?php } ?>
</div>
</div>
<!--#end of box content-->
<?php
} //end of boxes
?>
<!--#end of box content-->
<!--default content on page-->
<?php while ( have_posts() ) : the_post(); ?>
<?php if ( has_post_thumbnail() ) : ?>
<div class="entry-page-image">
<?php the_post_thumbnail(); ?>
</div><!-- .entry-page-image -->
<?php endif; ?>
<?php get_template_part( 'content', 'page' ); ?>
<?php endwhile; // end of the loop. ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar( 'front' ); ?>
<?php get_footer(); ?>
I have used this in my functions.php file to make it woocommerce compatible,
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
add_action('woocommerce_before_main_content', 'my_theme_wrapper_start', 10);
add_action('woocommerce_after_main_content', 'my_theme_wrapper_end', 10);
function my_theme_wrapper_start() {
echo '<div id="main">';
}
function my_theme_wrapper_end() {
echo '</div>';
}
However, it did not work. Only the product shows up spanning full width on the page and default sidebar lies at its bottom.
I need some help on this. Can you give me any ideas?
Best is that you use the "template overwrite" method:
Copy the woocommerce/templates/ folder inside your theme folder, to yourtheme/woocommerce/
Inside that folder, you can modify the html structure to your heart's content and it will be used instead of woocommerce standard html templates.
Once this is done, open up these two files:
/wp-content/themes/your-theme/woocommerce/shop/wrapper-start.php
/wp-content/themes/your-theme/woocommerce/shop/wrapper-end.php
and modify the html to match yours.
there are two method one is Using woo commerce_content() and other is Using hooks so please follow first method to merge woo commerce in to your theme that documentation for merge woo commerce in to theme if you do not follow it willbe harmful for your theme design .....

wordpress the_content not working on page template

i have a WordPress template page, which shows header, footer and sidebar, but the content not showing up anyone can help?
<?php
/**
* Template Name: Template 2
*/
?>
<?php get_header(); ?>
<div class="main_right" style="float:right;">
<?php get_sidebar(1); ?>
</div>
<div style="float:left">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php echo the_content();?>
<?php endwhile; endif; ?>
</div>
<?php get_footer(); ?>
Is this within your wordpress loop? It has to be in order for the_content to work.
Also, you don't need to echo the function, just place it in your file like so…
<?php the_content(); ?>
Also, why would you want to wrap the content in <p> tags? Wordpress does this for you automatically. If you want to wrap it something a <div> would be much better, probably with a class or id for css use.
Have you had a look at the wordpress codex? - http://codex.wordpress.org/Function_Reference/the_content

Resources