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

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();

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.

Two pages with same content

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

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).

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