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

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.

Related

simple html site to wordpress and edit visually

I am converting a very simple html site to WordPress. I made a very simple folder like,
custom_theme
header.php
front-page.php
about.php
footer.php
I cut all the code from index.html and spared them into header,footer,front-page,about.
then in the wp dash board i created those page and select the template. The site is working fine.This is the live site
http://www.mannmechanicalhvac.com/
Now i want to edit the content and image from wordpress visually not from code. Is their any possibility to do that?
###thanks in advance.
A very basic example:
<?php while ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<div class="page-content"><?php the_content(); ?></div>
<?php endwhile; ?>
the_content() outputs the content which was entered in the editor.
This is a good starter theme: _s from Automattic
or: http://underscores.me/
Recommend to read:
Stepping_into_Templates
Theme_Development
Template_Tags
template-hierarchy
The_Loop

Wordpress showing post info under new pages, but I want it to show only under new posts

I have basic loop to show PHP posts
if (have_posts()) :
while (have_posts()) : the_post(); ?>
<div class="post">
<h2><?php the_title(); ?></h2>
<div class="post-info"><?php echo get_the_date(); ?> - posted by <?php echo get_the_author(); ?> </a></div>
<?php the_content('<button class="show-more">Saznajte više</button>'); ?>
</div>
<?php
endwhile;
else :
echo "<p>No posts</p>";
endif;
It is the line that has <div class="post-info...
Now it is working very well, it shows date and author under post heading, but it also shows that when a new page is created. I understand Wordpress works like blog and it is natural for it to treat new pages as posts, however I want to avoid that behavior. I only want it to be shown under post headings, but not under new page headings. What would you suggest me?
https://developer.wordpress.org/themes/basics/template-hierarchy/
Check this template hierarchy and you'll understand how WordPress call template files.
Basically, WordPress firstly runs index.php and then call different template files. Since you only have index.php, so when rendering pages it all also falls back to index.php.
What you can do is creating a page.php with its own design for WordPress to call properly.

How to create a single post page in wordpress theme?

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

Wordpress Latest Blog Entries Plugin for Website

I would like to display my blog entries on my website in an iframe or whatever suggested method is. Can somebody please advice how to do that?
Thanks in advance.
Hi,
There are multiple options to do this I am mentioning three of them:
Menthod # 1
You can create a page template in wordpress and than using that page template create a page. Now you have the URL you can use that page in iFrame on any website.
Method # 2
Create a file at the root level of the server with this code:
<?php
// Include WordPress
define('WP_USE_THEMES', false);
require('wp-load.php');
query_posts('showposts=1');
while (have_posts()): the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_excerpt(); ?>
<p>Read more...</p>
<?php endwhile; ?>
Now you can call this file in the iFrame and you have the latest posts.
Method # 3
You can use the rss feed from wordpress and either use PHP or jQuery to style it.
Thanks
Peachlabs

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