How to create a single post page in wordpress theme? - wordpress

I am new to wordpress theme. I have created a wordpress theme by creating index.php and style.css. This theme is actually a blog theme. So, i have designed all the section in index.php and that is my front page and i have write the php code to display the blog post from the wordpress automaticaly. It works fine.
My question is, when i click on the title of the blog post it goes to the next page which indicates mysitenamedomain/post-id and i seems nothing on that page. whether i want to create a single.php page to display the title, content etc on that page?

In single.php you have to use loop
Here is documentation: Codex
Try: (in single.php):
<?php while ( have_posts() ) : the_post(); ?>
<h3><?php the_category(' › '); echo " › "; the_title(); ?></h3>
<?php the_content(); ?>
<?php endwhile; // end of the loop. ?>
Of course you have to style it.

login admin panel and create a new post here by clicking the "POST" menu of dashboard, put the post title and post content here and then save it . after that check single page on website it will display the title , content etc

Related

Page layout (page.php) doesn't apply to pages

I made few pages in my admin panel. Then created page.php with this code inside
`<?php get_header(); ?>
<section>
<?php if (have_posts()): while (have_posts()): the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
</section>
<?php get_footer(); ?>`
Set one of this pages as "homepage". And when i open site it shows me header, footer... everything it should, but when i try to open any of the other pages, I get 404 page...
Help me please, where i have to search for mistakes?
Thank you
You need to define one of the following: index.php (REQUIRED), home.php, or front-page.php.
Here's the way template inheritance works for the home page:
WordPress looks for front-page.php, regardless of whether or not your site is set up to show a static front page, or your most recent posts
If front-page.php doesn't exist, WordPress looks for home.php
If no home.php is set, WordPress defaults to index.php
You can read more about template inheritance in the codex.

How to have a folder structure in a wordpress template (For ex : http://www.example.com/products/story)

I am new to wordpress and trying to get my head around it. I figured that I can create a custom php file as
<?php
/*
Template Name: The Story
*/
?>
<?php get_header() ?>
<?php get_sidebar(); ?>
<div class="story_content"><?php echo get_option('story-content') ?></div>
<?php get_footer() ?>
and in the admin panel , I can add a new page and choose "the story" as the template , which will in turn , give me an URL as http://www.example.com/thestory
But for the life of me , I can't figure out how to have a directory structure in the website such as http://www.example.com/products/thestory
Can someone help me out here.
Thanks already!
You can achieve this with "Pretty Permalinks" enabled in WordPress, by simply creating two pages:
A Products page with a slug of /products
A The Story page that is a child of Products (i.e. The Story has a parent post: Products). You'd make this slug /thestory (it will automatically be appended to the parent slug: /products)
This can all be done from within the Dashboard Pages area, without editing templates.

Single Page Wordpress Template

I have to convert the following HTML website into a Theme for Wordpress. I am trying to figure out how to structure the theme in terms of pages/posts/custom modules and themes.
I have 5 sections in my page
Home (Slider and content)
Know (tabs with content)
View (Projects with filterable effect)
Read (blog and articles)
Talk (contact Form)
I want to allow the customer to be able to edit most of the content on the page.
Please guide me into getting started.
Link: http://play.mink7.com/sophiance/
*Edit*
I created a page called 'home' and in settings>reading> selected that as the static content for the site.
Next i created a template called template-home.php and selected the home to use this template.
in your index.php file put the 5 sections.
in each section - create a new query to pull a page.
for example with a custom post type
<section id="home">
//Slider Content
<?php query_posts('pagename=home'); if ( have_posts() ) while ( have_posts() ) : the_post(); ?>//Loop Content
<?php endwhile; endif; wp_reset_query(); ?>
</section>
<section id="know">
<?php query_posts('pagename=know'); if ( have_posts() ) while ( have_posts() ) : the_post(); ?>//Loop Content
<?php endwhile; endif; wp_reset_query(); ?>
</section>
etc.
Then create each page with that name and it will pull the data
I created a site like that here
This is how you should structure your Wordpress website:
Home (Slider and content) - create a page called Home and a custom page template called home
Know (tabs with content) - use a shortcode plugin to have tabbed content, default page template
View (Projects with filterable effect) - use a plugin that displays content in a masonry layout, default page template
Read (blog and articles) - create posts (under posts) and display them using the post archive.
Talk (contact Form) - use default page template and a plugin like Gravity Themes for the contact form
For similar ideas on how to structure your Wordpress website go to http://www.mybuzzmedia.net

Featured page in wordpress sidebar

I want to add a 'featured page' button/widget to a sidebar in Wordpress that will show a thumbnail of the page as well as the page's custom excerpt (I'm using http://wordpress.org/extend/plugins/page-excerpt/).
I got it sort of working using either a custom text widget or http://wordpress.org/extend/plugins/featured-page-widget/ but it doesn't show the excerpt, it just generates one from the page's main content.
Anyone know an easy way to do this? My hope was for non-web designers to be able to update this kind of content.
You can easily achieve this by activating this plugin http://wordpress.org/extend/plugins/php-text-widget/ You can put your php code in the widget. This means you can also put your WP_QUERY, query_posts or get_posts loop in order for you to get the page you want.
Activate the plugin go to your widget page use the text widget and drag it to your widget area and paste this
<?php
$the_query = new WP_Query();
$the_query->query("page_id=$page_id");
if ($the_query->have_posts()) :
while($the_query->have_posts()) : $the_query->the_post();
//show thumbnail
if(has_post_thumbnail()) :
the_post_thumbnail();
endif;
//show excerpt
the_excerpt();
endwhile;
endif;
wp_reset_postdata();
?>

How do I make a Wordpress Page act like the default home page displaying multiple posts?

I basically want a Wordpress "Page" that acts just like the home page and loops through recent posts and displays them. How do I do this?
If you go to Settings->Reading and then for "Front Page Shows" select static page, and then select a page from the dropdown, then edit the source code for this file to include a standard WP loop like -
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<h2><?php the_title() ?><h2>
<?php endwhile; endif; ?>
Use the wordpress loop, but you can control which posts show up in the loop using query_posts()
http://codex.wordpress.org/Template_Tags/query_posts

Resources