Content written in the Page edit box not showing in the published page in Wordpress - wordpress

I am not sure what I am missing. Please guide me and I apologize if my knowledge is too less.
I have a home template file i.e. template-home.php which actually contains nothing for now and is only containing the following lines ->
<?php
/**
* This is the front page code
* Template Name: HomePage
*/
get_header();
get_footer();
?>
I have created a page from wp admin and given the page title "Home" then I selected template "Homepage" for this page I have created from wp admin. Hence I have set the static front page to display "Home". Its perfectly showing the Home page as front page. But when I am giving any content in the edit box of the page "Home" from wp-admin and updating, those contents are not displaying in frontend. But if I put any content in the "Homepage" template , only then its getting displayed. I am giving an example what I tried below-
When I am giving the following in the page edit box then nothing is displayed in real.
[rev_slider_vc alias="homebanner" title="Home Slideshow"]
For your information the above is shortcode of revolution slider which is working perfectly , if I use it in any post. So the shortcode has no error for sure. Another thing whatever I write in the content box is actually not getting displayed in real.
Now the slider code, if I am putting directly into the Home template i.e. template-home.php then slider is getting displayed. The code is as follows ->
<?php
/**
* This is the front page code
* Template Name: HomePage
*/
get_header();
// Revolution Slider
putRevSlider('homebanner', 'homepage');
get_footer();
?>
Though my purpose is getting served well by putting code into the template file directly. But I want that the content I put in the edit box of the page from wp admin can get displayed in real. So what I need to do for that ?

Read https://codex.wordpress.org/The_Loop and https://developer.wordpress.org/reference/functions/the_content/
You need a loop and you need the_content to grab the content from the text editor.
A very basic example:
<?php
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
//
// Post Content here
the_content();
//
} // end while
} // end if
?>
Work with that first with some plain text to test the loop.
Then add your shortcode for the slider [rev_slider_vc alias="homebanner" title="Home Slideshow"] in the text editor. And, look at the docs for the slider on how to place the function putRevSlider('homebanner', 'homepage'); directly in the page template file, if you want to do that rather than using the shortcode in the editor.
See https://codex.wordpress.org/Theme_Development for how WordPress themes are structured and the types of basic files you need in each theme, i.e. index.php, style.css, etc.

Related

how to move the physical location of the permalink header in wordpress?

Does anyone know how to move the physical location of a permalink header in wordpress? I dont want it to be the first thing that is seen but rather I want a shortcode item there.
In your page.php you can delete the php function for calling the header ( the_header() ) and put the function to call the shortcode ( do_shortcode() ).
This way the page is not embeding the header.php but get the code of your shortcode at this place of your markup.
Page Template:
You can create a page template in your theme-folder. For this, you can simple duplicate the page.php and call it page-yourname.php. At the top of your page you add the name of the page template:
<?php /* Template Name: Example Template */ ?>
In that file you do the adjustments that you like to do with the shortcode.
https://developer.wordpress.org/themes/template-files-section/page-template-files/
With the template structure of wordpress, the template will automatically be found at the edit screen of your pages. It will be found on the right side under "page attributes".
You can set the template for your individual pages. So your adjustments to the template will only affect your pages, where you selected the template in the page attributes.

Custom page template displays the archive template

I have a custom page template named "page-news.php" and it contains
<?php
/*
* Template Name: News
*/
get_header();
?>
test
<?php
wp_footer();
get_footer();
?>
and I then create a page and set the template to "News" but when I view the page, it does not display the contents on the page-news.php custom page template, instead it display the archive.php contents (I have test it, whatever I put unto the archive.php contents, it display on the page that I hook unto the page-news.php custom page template). Any ideas, help please? I'm running WP 4.7.2.
Please rename the file name i.e. from 'page-news.php' to 'news.php' or any other name but don't add 'page-' in the file name & then select the template again for the page in the admin backend.
Hope, this will help you.

how to add wordpress theme in page which take template of external php file

I want to make php file "demo.php" in geany editor and then I want to add that page in my website.To do this task I have add "demo.php" in folder "wordpress/wp-content/themes/my_wesite_theme" ,after that my wordpress show that file as template "demo" , up to this its ok.
After that i want to add new page "new-page-of-site" in wordpress which take template of "demo" which is my php file template ,after selection of that template when i view "new-page-of-site" in browser it show only output of that page without wordpress theme ,so how can I include wordpress theme in that page.
This is a simple process and is very easy to do.
First of all, you need to name the template correctly. This just means adding the prefix page- before the name of the template. Like so:
page-demo.php
Next, you have to add a tiny bit of code to the top of the template page just so that WordPress will know what the template is called.
Open up the new page-demo.php that you have created, and add this code to the top:
<?php
/*
Template Name: Demo
*/
// names the template
get_header(); // gets the header detail
?>
<?php
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
//
// Post Content here
//
} // end while
} // end if
?>
<?php
get_footer(); // gets the footer detail
?>
I've added some code for the actual page but you'll want to change it up to fit your actual page layout.
When you get into the WordPress admin area for adding new pages, on the right hand side below the save button, you should have an area for changing the template, just choose the new option, save and then you should be able to view the page with the new template.

How to differentiate Front page and other pages in Wordpress?

I have created a front page (i.e index.php) with my own design. This page will contain
header got from <?php get_header(); ?> [has navigation bar code]
Then some content. Here I'm showing three thumbnails of posts. [has slider, thumbnail posts etc]
And a footer from <?php get_footer(); ?>[has footer links]
The problem is, I see index.php loaded correctly as a front page. But when I navigate to other pages like About or Contact, the respective content from these pages is not showing up. Instead what getting loaded there is, same what Index page has. I don't want slider or thumbnail appearing on these pages.
So how to tell wp that, this is my front page, and this is my About page, don't load a slider and stuff on About page!?
use is_front_page() to determine the home page. like you only want slider on the home page then edit your header.php file that consist the slider part and do something like this
if( is_front_page() ):
// Front Page stuff like slider and
// whatever you want
endif;
Try this ,
if( is_home() || is_front_page() ){
//your home page content
}
else{
//other pages
}
For more here
Hope its works..
Make another template and set this template for your single pages. And then from backhand set it.
I usually create a front-page.php file, Wordpress will use that instead of index.php (which you can use as a generic template from then on).

Make another content list as content file of wordpress

I have page I want to display the page in different style (not as the content.php file ) so now I made copy the content.php file and just modified it. I want to display only for one page and other pages should display like content.php . So how can I change the index page to display the particular as new content-list page. My page name is News and it should be display like content-list.php.
For display indiviual page you have to make a Template for that page and from
Dashboard-->Pages open the page where you want to display that template, on right hand side you have seen TAMPLATE-->DEFAULT TEMPLATE, select template you have created...
Syntax for new template
<?php
/*Template Name:abc
*/
?>
<?php get_header();?>
<!--------------------------------------->
CONTENT FOR PAGE
<!--------------------------------------->
<?php get_Footer();?>
I don't know about which file you're referring to as content.php
I have page i want display the page in different style
So, if you want to display a page with a different style, you should have a look at WordPress Template Hierarchy.
You can create another page template, use custom files like header-{name}.php and footer-{name}.php and use get_header() and get_footer() with the appropriate arguments(the {name} you mentionned to call these files.

Resources