How do I know which file to edit in wordpress? - php

I have a website in WordPress and I've noticed in some points I want to change a piece of text or something similar, but I don't know which file to edit.
How do I locate the file that I want to edit using FTP (for example using FileZilla) in order to change the website detail that I want to?

Long story short, there's going to be more than one file. A good place to start is by looking at the class of the body tag. Generally it references which templates the page is using.

It's a very big topic to discuss.
If you want to edit any content of the page you can edit page.php file which is located in your Theme folder e.g. (wp-content/themes/theme-name).
If you want to edit any content related to post you can content.php which is again related to your theme folder.
If you want to edit sidebar content edit sidebar-content.php file (located in your theme folder).
There are other templates as well. But all the template files are located in your theme folder.

Related

Where do I find my custom page in WordPress?

I might get in trouble for asking this but I have been searching WordPress web directories and scouring the web.
I have not been able to find the file based on everything I have read so far.
I copied the contents of a template file called page.php and created a page called page-contact-us.php.
After editing this page, I uploaded inside the themes folder along with the same page.php file I modeled after along with several other files.
How do I find page-contact-us.php file when I log into my wordpress web app?
Thanks
When editing a page in WP-admin, there will be a box off to the right hand side (under the Publish area, typically) that holds a drop-down for selecting the Page Template to use for that page.
As long as you've set up the template comment at the top of the template file, your custom template should show up here. At the start of the file, include this:
<?php /* Template Name: Your Template Name Here */ ?>

How do I use an Inspector to find the HTML in a theme's PHP files?

I'm working on a Wordpress website for someone and I have a question. I used an inspector (firebug) to check out the html of my site but I need to know where to find that bit of code in the Wordpress theme (Spacing) php files. There's no search all feature and going through all of them separately is ridiculous.
I really appreciate any help you can offer!!
I found an article on it (https://wordpress.org/support/topic/search-through-php-files) but there really wasn't a solution. If I can find what I'm looking for in the HTML (it's a menu name by the way), why can't I go find it in the theme files??
I don't know if this matters but the HTML is a body class to a couple of div classes to a ul id to li id to an a class.
WP does not contain ant HTML page. Everything in WordPress php file. If your page is created in page section you have to check in page.php file in /wp-content/themes/{your theme name}/page.php or if your page is posts you to check in post.php
What you want to change in WordPress site ?
If you go into the back-end/admin section and click "Pages". Find the page you are working on and click edit. In the "Page Attributes" you can see what "Template" it is using.
Then you can find that template in /wp-content/themes/yourtheme/
EDIT: More than likely the header and navigation is located in the "header.php" file in the themes folder.

How do I edit an individual page in WordPress

I don't want to edit the template files - I'd like to make a new template file. I'm looking in the MySQL registry, but all I see is a table for posts, not pages. Someone mentioned the editor earlier, but that doesn't help with creating new templates.
I think I create a php file in my content>theme>my_theme directory, but I'm not certain.
Thanks for any help.
This should help you out:
It shows you which pages map to which template, and how new templates should be created. As an example, if you created an About Us page (singular, static page with the default page template), here's what Wordpress checks for:
Is there a file called page-about-us.php?
No? Is there a page called page-#.php (where # is the pageid)
No? Just render the generic page.php
In your case, if you want to edit a single page (it's a page right, not post?) .. then simply creating a file called page-$slug.php would be sufficient .. WP will use that "template" when rendering that page.
If it's still a bit unclear, check out the source link here (it makes things crystal clear!): http://make.wordpress.org/docs/theme-developer-handbook/part-one-theme-basics/template-hierarchy/
You can create your own template files in your theme directory, or a subfolder. Use a comment on top that has the name of the template.
/*
Template Name: Custom Template
*/
You can assign the template to a page under the "Page Attributes" box in the dashboard.
Of course you need more than just that comment to display anything in your template. You might stay by copying the content of your theme's index.php, then edit from there.

Wordpress - all pages link to the index.php file

[NEW AT WORDPRESS]
I'm creating my own wordpress theme with own css etc etc. I've managed to get everything good in the index.php file, and I'm trying to make the other pages as well now.
When I make the home.php, blog.php, about.php and contact.php file (in my theme folder) they don't link to it. I'm following the "WordPress 3: Creating and Editing Custom Themes with Chris Coyier" on Lynda.com and the example shows that whenever you make a file with the same name as your page, it takes that directly (which works at his tutorial).
Anyone that could know what is going on?
Example:
I got a file blog.php in my theme folder, and when I go to www.mydomain.com/blog the loaded file is the index.php file, instead of the blog.php file
There are two ways you can get this working using custom page templates.
Create a template for one specific page using the page slug or ID. In this case, change the name of the php files like this to match the name of the page you created in the UI: page-home.php, page-blog.php, page-about.php and page-contact.php
Much more flexible is to create a custom template that can be used on ANY page. Just add the template name to the top of the php file like so (inside the php block):
/*
Template Name: My Home Page Template
*/
Then edit the pages and select your custom template from the template dropdown menu (on the right hand side I think, if its visible).
Reference this page for more info: https://developer.wordpress.org/themes/template-files-section/page-template-files/
Found the solution to my (silly) problem.
Creating a page in your theme directory & adding the template comment at the top of your php file isn't enough. You need to go to the admin panel->pages->YOUR PAGE-> and check out the page attributes. There you can link the page to a certain template: http://d.pr/i/a0m0

Include HTML form and form processor in Wordpress

I'm not at all familiar with Wordpress so please bear with me...I have a site on Wordpress. On the homepage is where I want to include an HTML form which would post to a it's own PHP processor. The form and the form processor are both separate PHP files. I would like to know how I can include the form in a specific DIV on my homepage. Any assistance is greatly appreciated.
Look inside the folder wordpress/wp-content/themes/twentyeleven/ for the files home.php or index.php.
If you want the form in the main content area that's where you need to put it (use an include to your PHP file).
If you want it in the sidebar there's a sidebar.php file you can check out.
If you change the theme twentyeleven be sure to rename the folder and open the style.css file and change the name in the css comments too. After that you can enter the wp-admin area and select the new theme from the appearance panel. You should do this so that any WordPress updates won't overwrite the files you change.

Categories