Two pages with same content - wordpress

How to create two pages with same content?
For example, the first page should be with a header menu and the second page should be without a header menu.
The page of my theme has an options without header
Or I can use two different templates of page, but the content of pages should be the same.

You can read the documentation here.
Create a file, called page-mytemplate.php under your theme directory.
In that file, start with this:
<?php
/*
Template Name: My Custom Page
*/
Create a page, and set the template to My Custom Page.
At here you can do whatever you want.
For the other page, repeat the steps, but just call the other template something different name.
EDIT
When you want to show the same content with different templates, just simple get the content of the page:
$post = get_post($postId);
echo $post->post_title ."<br />";
echo $post->post_content;
You can wrap this with your two template page. See the documentation here

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.

Wordpress: How can I create a page template out of an existing page?

I need to apply the same content on over 4000 Wordpress pages. Now to make it as easy as possible. I create a single page and designed it with the content. So what I want to do now is create a template out of this page. Is there any possibility to export the page as php code to put it in the theme as a template?
(It hast to be the exact content as the template file)
I am also open-minded for other Ideas to solve this problem. Thanks a lot!
Yes, you can create a template and apply your template to your pages.
With the content that you wish to apply to your pages, create a .php file. At the top of this.php (called say page-mycontent.php) file add this header:
<?php
/* Template Name: My Template */
?>
Now the template will appear in the admin panel for Page - Edit on the right hand side.
Code Changes in header.php and page.php
Your changes are in both the header and the loop. So I suggest creating two templates, one for the header and one for the body.
In your header.php, if you name your header code as header-myheader.php then pull your new header template into header.php like so:
<?php get_header('myheader'); ?>
And similarly add your body code (called mytemplate.php say) into page.php like so:
<?php get_template_part('mytemplate'); ?>

Archive displayed on a custom page to be used in menu structure

I would like to direct users to appropriate archive pages from within the menu. If I want this I need a page that I can attach to the menu.
How would I display the exact same stuff as on the archive page (archive.php) on another page so that pagination and functionalities remain the same, but some stuff will be taken from the actual page ? (can create custom page template of course)
I'll still have to show a sidebar for the page that you visited and not archive's sidebar
Breadcrumbs path will still have to show current menu item position and not archive page path
To show sidebar from the actual page is of most importance here.
EDIT
What I want to achieve is this actually:
Lets say I have a page
http://my.page/subpage/something/notifications/
I want that on this page, I can display exactly the same stuff as on the certain archive page which is here:
http://my.page/subpage/notification/
('notification' is a custom post type here)
I already have a solution that displays all archive stuff on another page (created a page template for that), but its a bit complicated to display title, breadcrumbs and sidebar properly for each page, since some of these should stay the same as they would be, but some should take the value of another site.
You can create a custom page template and assign it to a page. On that page you can use get_posts() to query the posts you want, like this:
global $post;
$posts = query_posts( /* Your args here*/ );
foreach($posts as $post) {
setup_postdata($post);
// Do your stuff as in archive.php
}
wp_reset_postdata();

Wordpress pages theme/layout

I'd like to know whether I could have different layout and content for each page?
For example, I have 4 pages, and I have 4 completely different layout design, do I need to make 4 themes then apply to different pages or something else?
Moreover, can I have different posts show on different page?
like post no.1/or tag [google] goes to page 1, post no.5/tag[orange] goes to page 3?
I'd like to learn how to structure this idea.
Many thanks
make the diffrent template for different pages to show the different design on every page
for making template create normal php file and at the top of file add the code for every template by replacing template name
<?php
/*
Template Name:About Us
*/
?>
By this you get different template for about us put you code desing that you want to show for this page and from that back end select the template from rignt hand side option and save that page .
And to show different post on different pages you need to create category after that where you want to call the post for page call the category code for that
<?php Query_post('cat=3&showposts');
while(have_posts()): the_post();
the_title();
endwhile; wp_reset_query(); ?> every time on different page you just chage the category id (cat)

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