contents of page.php does not show in wordpress - wordpress

I have updated my site on localhost and uploaded to server (000Webhost) then the contents of page.php(all other template as well) does not show anymore. However it still work fine on localhost. I thought something gone wrong in Wordpress on server so I have deleted database and recreate them and also reinstall Wordpress and then uploaded my theme but still not working. Does anyone know what is happening and what I am doing worng?? My page.php is very simple like this below, Oh the title is showing but not the contents.
<?php get_header(); ?>
<div id="content">
<h1 class="entry-title"><?php the_title(); ?></h1>
<p>
<?php the_content(); ?>
</p>
<div style="clear:both;"></div>
</div>
<?php get_footer(); ?>
here is the site.
http://ahi.webatu.com/?page_id=12
Thank you very much in advance!!

You need to be in the_post() scope to use the_content() function as you want
<?php if( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endif; ?>

Related

2 issues with my WordPress blog

http://www.florence.inspiremeland.gridhosted.co.uk/
I tried every single possible way to remove my feature images from my single posts while keeping the images when you visit my home page.
First of all I tried to use the following code:
.single-post .attachment-post-thumbnail {
display: none;
}
Along with many other in my style.css or single post file without any success.
This is in my single.php file:
<?php get_header(); ?>
<div class="container">
<div id="content">
<div id="main" <?php if(get_theme_mod('sp_post_layout') == 'full') : ?>class="fullwidth"<?php endif; ?>>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php get_template_part('content'); ?>
<?php endwhile; ?>
<?php endif; ?>
<?php if(get_theme_mod('sp_post_layout') == 'full') : else : ?><?php get_sidebar(); ?><?php endif; ?>
</div>
<?php get_footer(); ?>
Let me know what part you need from my CSS perhaps if you could help?
I am really desperate to solve this :(
2.
When I visit my blog posts the sidebar is below content and not at the side, my website is not live yet so I cannot show you that but if you could help I would really appreciate it.
Betty
Have a look at standard.php in includes/post-formats/ and you should find something like <?php the_post_thumbnail('thumbnail'); }?> which you can remove.

Wordpress Use Theme for Blog Only

I wish to use the Pinbin theme for my Wordpress blog only. I have created a custom theme for everything else, but for the blog, I would like to use this theme.
I took the main index php file from this template, along with the header and footer files. I renamed the header and footer files, and changed the header/footer calls to these files rather than the ones used by the rest of the site.
I assigned the theme to a page, but it's not showing any posts. The code is as follows:
<?php if (have_posts()) : ?>
<div id="post-area">
<?php while (have_posts()) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if ( has_post_thumbnail() ) { ?>
<div class="pinbin-image"><?php the_post_thumbnail( 'summary-image' ); ?></div>
<div class="pinbin-category"><p><?php the_category(', ') ?></p></div>
<?php } ?>
<div class="pinbin-copy"><h2><a class="front-link" href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<p class="pinbin-date"><?php the_time(get_option('date_format')); ?> </p>
<?php the_excerpt(); ?>
<p class="pinbin-link">→</p>
</div>
</div>
<?php endwhile; ?>
Any ideas on why I'm not seeing anything?
Thanks, S
The index.php file is used as a backup if there's no other template defined, you'll have to edit a different file if you want to edit a certain page type. See template hierarchy in the WordPress codex.
+
You forgot an endif; at the bottom of your file.

Why the_content doesn't work in wordpress single.php

My code:
<?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; ?>
I put the code into my customed wordpress theme file single.php. Why it can't output the post content, it can output the post title. thank you.
You can try the following to see if it works instead of the_content
<?php echo wpautop($post->post_content); ?> // content with p tags
<?php echo $post->post_content; ?> //without p tags
Also an option
<?php echo wpautop( get_the_content() ); ?> // content with p tags
see if that works for you.
When developing Wordpress themes it's advisable for you to switch the debug mode (found on your installation's root in wp-config.php) to true. This will alert you if you have any errors.
In your case, try out the <?php the_excerpt(); ?>.
Also, this may sound a bit dumb, but do you actually have posts? Not pages or rather content in that post?
Many a times i have come across queries from developers or first time theme developers about not able to show the_content() on their custom template page.
The issue is that the_content() function runs inside the WP loop so for example
if (have_posts()) {
while (have_posts()) {
the_post();
the_content();
}
} ?>
This will work, but in some cases you want to call the function outside the loop – the solution for that is:
echo $post->post_content;

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

custom wordpress theme echoes gallery short code

So i'm quite a beginner, trying to make a custom theme. In a page i want to have a gallery. Uploaded images, made a gallery all fine.
When I view the page it outputs only the shortcode:
[gallery orderby="post_date"]
my page.php file basically has:
<?php $content = get_page( $page_id ) ?>
<div id='content' class='shadow'>
<div id='innercontent'>
<!---page title-->
<?php echo "<h1>".$content->post_title."</h1><br>" ; ?>
<?php echo $content->post_content ?>
</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
I really don't understand how to get this to show correctly, any pointers would be greatly appreciated. Cheers, Matt
get_page returns the raw page data. There are a few ways to do what you want:
BAD WAY:
<?php $content = get_page( $page_id ) ?>
<div id='content' class='shadow'>
<div id='innercontent'>
<!---page title-->
<?php echo "<h1>".$content->post_title."</h1><br>" ; ?>
<?php echo do_shortcode($content->post_content); ?>
</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
do_shortcode() renders all registered shortcode that's found within a given string. In this case, your page's content will have all shortcode rendered before being written to the document. I say this is the "bad" way, only because it doesn't follow the usual Wordpress format. Which leads us to the:
BETTER WAY:
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<div id='content' class='shadow'>
<div id='innercontent'>
<!---page title-->
<h1><?php the_title(); ?></h1><br>
<?php the_content(); ?>
</div>
</div>
<?php endwhile;endif; ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
This is what's called "The Loop". It is pretty much the standard for all Wordpress Themes in retrieving all Post or Page Data, as well as running queries against the database.
I would suggest getting to know it, as well as running Wordpress queries to modify the loop using WP Query. This is getting into a more complex area of Wordpress, but it will help you in the longrun with figuring out how to gather up all of the posts and pages you want to retrieve in your theme that aren't provided by Wordpress' globals.
Good luck.

Resources