how does wordpress know what page to open - wordpress

Newbie to WordPress coming from Joomla. Trying to get my head around how wp knows to use base.php or page.php. also if I have a page called about us do I create a page called page-about-us.php and if so how does wp know to open it

Slug
Slug is a simple id of posts and pages. WordPress by default creates slug for Posts, Pages, Categories and Tags as long as we have not created a specific Slug. Slugs are always created in small letters with “-” sign in between the words.
Example
your page name is -> “about us“ the slug of that page will be “about-us”.
In this way,this will execute from page.php and if you want to customize it in your way make a page-about-us.php.

Related

WordPress get posts to show on home.php

Is it possible to have the loop display posts on home.php? I want to have a static front page using front-page.php and then have the loop show posts on home.php. I put a link to home.php however, it is not showing posts and it is pulling up the index page as well. I thought home.php took precedence for showing blog posts. The only way I can get posts to show up on another page is by using the dashboard and setting reading preferences. Is there a way to avoid this so a user that downloads my theme won't have to change reading preferences for the theme to work as designed?
create a custom function for fetching post in the function.php file and then display it through shortcode in any home or front-page file.

Add Posts page slug to Single Post permalink structure

Does anyone know if it's possible to place WordPress Blog POSTS in a unique directory?
In other words:
mywebsite.com/blog/Post-A/
mywebsite.com/blog/Post-B/
mywebsite.com/blog/Post-C/
I'd like to create /blog/ which I believe is done by creating a PAGE but that doesn't seem possible.
I've googled this for the last few hours and still can't figure it out.
The only way you're probably going to be able to do this without a plugin is by utilizing Categories and a custom permalinks structure.
Navigate to Posts > Categories
Add a new Category
Apply the Category to the desired posts
Navigate to Settings > Permalinks
Select Custom Structure and apply the following structure: /%category%/%postname%/
There are also plugins that expand endpoints and routing. https://wordpress.org/plugins/custom-permalinks/
If your goal is to not have the posts on the front page, you can also set the Blog page to a specific page in Wordpress.
Create two new Pages (not to be confused with a post)
Navigate to Settings > Reading
Set Front page displays to A Static Page
Select the Pages to be displayed for the Front page and the Posts page
The Blogroll (Posts page) will then appear under the endpoint of the defined Page's slug. However, the individual posts permalink will not have the Blogroll Page's slug in the route.

how to change full posts to excerpt on inner blog page WordPress

in WordPress I have an inner page called "blog", and in settings->reading I have that page assigned as the page for blog posts. I want that page to be excerpt instead of full posts. In the theme page.php is used for the (page) loop for the Blog page, but that's overridden by the assignment of blogs posts to that page and I can't simply change "the_content" to "the_excerpt" in page.php to make this work.
I need some conditional tag code to this happen (or would that even work?) in page.php, or is there another way to accomplish this?
The Wordpress template hierarchy diagram will help you out - Wordpress Hierarchy
Your page.php template displays an individual page, it will not be generating the blog archive page you want to edit. Depending on your theme that will either be category.php, archive.php or index.php.
Just change the relevant file to change the excerpt on your blog page.

Posts in Custom postype not visible on frontpage wordpress

I have created a custom post type restaurant. But Its not coming on the main page. But I'm able to see the post in single view when using the permalink. Is it that I have to make any changes in the index.php? If yes what changes? I'm using the default Twenty Ten theme in wordpress 3.
And how can I get only the custom post type in another page with pagination?
It's best to use postmeta for this instead of messing with the post_type as there is wordpress functionality which is depended on post_type.

Post pages in Wordpress 2.9

I'm trying to use a posts page in Wordpress. For the uninitiated, this is a page (other than the home page) which features all your blog posts. You essentially turn on the static home page and point Wordpress at a custom index. Then you tell Wordpress to use another custom template as your "posts page"; thereafter, any post you make will wind up there.
My custom template for the 'Blog' page shows up as expected until I define it as the posts page. When I do, the template reverts to my custom index and I get no posts. When I undefine it as the posts page, it goes back to my template. What am I missing? I'm new to using this method, as it used to be done with a plugin prior to WP 2.9
So, I figured out the solution and wanted to share. Thanks for all your input, everyone.
The problem was with the name I chose for the template. I had called it "blog.php", which works fine when creating an ordinary page template. But when using a page as a posts page, Wordpress has some specific setup rules. The pertinent section of documentation, which I scoured the entire internet for using hours of my life I'll never get back, is hidden here:
Also, any Template assigned the Page will be ignored and the theme's index.php (or home.php if it exists) will control the display of the posts. (from here).
So, I named my template "home.php", since I wasn't using a home.php in this particular install, and I was off to the races. Anyway, thanks for the answers!
BTW, I think this may have been what Richard M was getting at.
Your problem might be in creating "templates" and the single post (single.php) You can create a template for any of your pages by putting this in the top of your page (after the first < ? php:
/**Template Name: ****templatenamehere**** #package WordPress * #subpackage Default_Theme */
...rest of code
This allows you to create a page called "posts" which references your new template. This way you can create a new template and then call it through a page. If this is confusing or you have tried this let me know and I will try to give you more details if you need. Thanks

Resources