...

View Full Version : How to change a weblink in php file?



benobi
07-11-2012, 03:22 PM
Hi there

Apologies if I have posted this in the wrong forum - I'm a newbie who is rather lost with an issue that I am having with my website and could do with some guidance.

The reason why I've posted this in php forum is because the majority of the backend files on the server appear to be php files.

I had a website built for me by a web developer a couple of years ago and would now like to change the web address of a link that's on the menu header.

The current link is "Blog" and has the address http://www.website.com/category/blog. I want to change the address of this link to http://www.website.com/blog.

How should I go about doing this? I can access all the back end files using FTP, but don't know which file to modify.

To identify the link, I thought I would try to "View Source" while on one of the webpages - I can search for the link which brings up the following (i've copied what I think is the relevant snippet below):


<div id="navigation">
<div class="menu-header"><ul id="menu-mainmenu" class="menu"><li id="menu-item-16" class="menu-item menu-item-type-post_type menu-item-16"><a href="http://www.website.com/about/">About</a></li>
<li id="menu-item-15" class="menu-item menu-item-type-post_type menu-item-15"><a href="http://www.website.com/portfolio/">Portfolio</a>
.
.
.
.
<li id="menu-item-17" class="menu-item menu-item-type-taxonomy menu-item-17"><a title="Blog" href="http://www.website.com/category/blog/">Blog</a></li>
</ul></div></div>

Can anyone help please? Many thanks in advance.

Cheers

benobi

Keleth
07-11-2012, 03:45 PM
It looks like this is a wordpress site... is that true?

And nah, that code is not relevant at all, as if its a PHP site, and indeed a wordpress site, it has nothing to do at all with the HTML, its all about the PHP.

mlseim
07-11-2012, 04:20 PM
Log into the admin dashboard of your WP site.

Mouse to the "Appearance" item and within
that drop-down menu is a link called "Editor".

Now this is where things might be different.
Each theme author may name their PHP scripts
different things. On the list at the right of
the editor page, look for a file that might have
a name like:
header_main.php
header_blog.php

You're going to be looking for the PHP script that
displays that menu bar on your page(s).

If you view that file in the editor, look for the part
where the menu (navigation) is appearing. Copy
and post that script here.

The editor you're using is the tool you will be using to make changes.

=========

Alternatively, if that menu/navigation portion is not within the PHP script ...

Because themes are created by different authors, the theme features
are usually done differently. I sort of expect you may find something in
the admin section where you can modify a part of your theme. That menu
or navigation part you're talking about might be a "setting" for a part
of your theme ... where each of those menu links can be modified. So
instead of looking at the PHP scripts (templates), you'll be looking for a
"Theme settings, or theme features" link to modify content. This method
will be a different link in the "Appearances" tab ... not "Editor", but
some other name.


.

benobi
07-11-2012, 06:03 PM
Indeed it is a wordpress site - thanks for your comments so far. I will give it a go shortly to see if this works. Will let you know. Cheers!

benobi
07-11-2012, 06:31 PM
Log into the admin dashboard of your WP site.

Mouse to the "Appearance" item and within
that drop-down menu is a link called "Editor".

Now this is where things might be different.
Each theme author may name their PHP scripts
different things. On the list at the right of
the editor page, look for a file that might have
a name like:
header_main.php
header_blog.php

You're going to be looking for the PHP script that
displays that menu bar on your page(s).

If you view that file in the editor, look for the part
where the menu (navigation) is appearing. Copy
and post that script here.

The editor you're using is the tool you will be using to make changes.

=========

Alternatively, if that menu/navigation portion is not within the PHP script ...

Because themes are created by different authors, the theme features
are usually done differently. I sort of expect you may find something in
the admin section where you can modify a part of your theme. That menu
or navigation part you're talking about might be a "setting" for a part
of your theme ... where each of those menu links can be modified. So
instead of looking at the PHP scripts (templates), you'll be looking for a
"Theme settings, or theme features" link to modify content. This method
will be a different link in the "Appearances" tab ... not "Editor", but
some other name.


.

Hi mlseim

Damnit - I think the account that the web developer gave me is only the role "Editor", not Admin. Can't see any section in WP that matches your description for a drop down link 'Appearance' or 'Editor'. The only one I can see is "User Role Editor" but when I click that it says "access is forbidden".

Is there any other way I can make this change?

Cheers

Ben

Keleth
07-11-2012, 06:40 PM
If you're not an admin, you can go into the database to make changes directly, but its difficult to do without screwing up the database without a decent understanding of mysql/php.

mlseim
07-11-2012, 07:57 PM
Ben ...

Let me take a look at this later when I am able to get into my MySQL account
and see where the users database is stored. I wonder if there might be a column
in the user's table where you could change your level from editor to admin.
I'll look closer to see, and let you know what I find.

But you are correct ... you'll need an admin login to do this.

mlseim
07-12-2012, 01:10 AM
Ben ...

Are you able to access the MySQL database using "phpMyAdmin"?
That's the program to access your database using your control panel?

Let me know if you can get that far.

If you can, try to find your "user ID" in the wp_users table.
Then, this script will allow you to switch levels:
http://www.redbridgenet.com/wordpress/a-script-to-update-wordpress-user-role-capabilities/


.

benobi
07-12-2012, 06:49 PM
Ben ...

Are you able to access the MySQL database using "phpMyAdmin"?
That's the program to access your database using your control panel?

Let me know if you can get that far.

If you can, try to find your "user ID" in the wp_users table.
Then, this script will allow you to switch levels:
http://www.redbridgenet.com/wordpress/a-script-to-update-wordpress-user-role-capabilities/


.

Hey there

Yes I can access phpMyAdmin via cPanel.

I found the following databases, but not sure what to do with them?


_wrdp1
_wrdp2

information_schema

Bit scary though as to what I am doing so maybe I should run through this with you on a private chat first.

Cheers

Ben

Keleth
07-12-2012, 06:53 PM
In the root of your wordpress install, you'll find a file called wp-config.php, and in there it'll tell you what database your site is using. Go to that database through PHPmyAdmin then follow the instructions on the site mlseim listed.

benobi
07-13-2012, 11:06 AM
Hi all

Thanks so far for comments on this. I've checked the wp-config file and the _wrpd2 is the correct DB. (the _wrpd1 DB is the DB for my new blog)

However.... I wonder if there is another option here?

I've just logged into the wp_user table for _wrpd2 and I see a user_login account called "admin", which speaks for itself I guess.

There are also a number of columns in this DB, one of them is user_pass with a character string showing for each account (is this a hex string?)

Rather than hack the DB to change the role on my editor account, can I just extract or change the password that is showing up under the admin account?

There's the option to Edit each user account, and there appears to be a password field under the options. But I don't want to change anything yet without some advice.

Thoughts?

Cheers

Ben

mlseim
07-13-2012, 12:28 PM
That password is encrypted. You can't decode it.

When you look at those names in that DB table, what is your user ID?
If there are 4 users, the user ID will be 1,2,3 or 4.

Keleth ...
Ben knows what his password is ...
What do you think about the idea of Ben using the phpAdmin to copy his
encrypted password and pasting it in the row for the admin user?
He'll be changing the admin password to his own.

That might work?


.

benobi
07-13-2012, 12:49 PM
That password is encrypted. You can't decode it.

When you look at those names in that DB table, what is your user ID?
If there are 4 users, the user ID will be 1,2,3 or 4.

Keleth ...
Ben knows what his password is ...
What do you think about the idea of Ben using the phpAdmin to copy his
encrypted password and pasting it in the row for the admin user?
He'll be changing the admin password to his own.

That might work?


.

The Admin ID=1.
My Editor ID=3.

I tried copying and pasting my encrypted password into the password field of a guest account (which I had set up a while back) to test whether it would pick up my password. It certainly did! I changed it back to the original encrypted password and again it updated ok.

But can someone confirm if this would be ok to do the same on the admin account? Or because this is special account, would it be a problem to do this?

Arcticwarrio
07-13-2012, 01:02 PM
yes this will work

mlseim
07-13-2012, 01:30 PM
Yea .. .try it.
You don't know the admin password anyhow, so you can't make it worse than it is.

If that does work, you should be able to log-in as admin and then
edit your templates. If you already have FTP access, you could edit
them manually (without logging into WP). I originally assumed you
were not comfortable with editing the PHP files using FTP (and Notepad).

benobi
07-13-2012, 02:08 PM
OK I now got into WP with the admin account.

I've looked over the options in Editor as described but couldn't see anything related to the blog link.

Here's the code from the "Navigation" link - it doesn't have any weblinks listed though. Just seems to refer to a couple of the menu items only.




<div id="navigation">
<?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>
</div>
<script>
$(document).ready(function() {

if ($('body').attr('id') === 'portfolio') {
$('#navigation ul li.menu-item-14 a').mouseover(
function() {
$('#navigation ul li.menu-item-15 ul').hide();
}
);

$('#navigation ul li.menu-item-14 a').mouseout(
function() {
$('#navigation ul li.menu-item-15 ul').show();
}
);
}

if ($('body').attr('id') === 'services') {
$('#navigation ul li.menu-item-15 a').mouseover(
function() {
$('#navigation ul li.menu-item-14 ul').hide();
}
);
$('#navigation ul li.menu-item-15 a').mouseout(
function() {
$('#navigation ul li.menu-item-14 ul').show();
}
);
}

});
</script>

benobi
07-13-2012, 02:56 PM
And here is a list of the options down the right hand side of the Editor screen. Do any of these sound familiar? I've looked through a bunch of them but couldn't find any references to the blog site.


Templates

404 Template
(404.php)
Archives
(archive.php)
Attachment Template
(attachment.php)
Author Template
(author.php)
Category Template
(category.php)
Client Login Page Template
(page_clientlogin.php)
Comments
(comments.php)
Footer
(footer.php)
Header
(header.php)
Main Index Template
(index.php)
One column, no sidebar Page Template
(onecolumn-page.php)
Page Template
(page.php)
Search Results
(search.php)
Sidebar
(sidebar.php)
Single Post
(single.php)
Tag Template
(tag.php)
Theme Functions
(functions.php)
google.php
(google.php)
head.php
(head.php)
loop.php
(loop.php)
navigation.php
(navigation.php)
phpinfo.php
(phpinfo.php)
setvariables.php
(setvariables.php)
sidebar-footer.php
(sidebar-footer.php)
variables.php
(variables.php)

Styles

RTL Stylesheet
(rtl.css)
Stylesheet
(style.css)
Visual Editor Stylesheet
(editor-style.css)
editor-style-rtl.css
(editor-style-rtl.css)

mlseim
07-14-2012, 01:18 AM
Is it possible for us to see the actual website?
If I can view the HTML, I can determine where that HTML is being generated by your script.

Good job on getting this far ... to the admin login.
You're going to really need that if you are the one making site changes.
And as a side note ... the previous person using the admin will no longer be able to login.

benobi
07-14-2012, 10:55 AM
Hi All

I've solved my question!

Now that I have access as an admin, all I needed to do was this in WP:

In Wordpress, click "Appearance"
From the dropdown list, select "Menu"
This brought up a menu list that corresponded to the header menu.

I then deleted the current "Blog" link in the active menu list.

Then under the "Custom Links" section, I entered the new blog address and gave it the label "Latest Blog Entries" and then saved it.

Bingo!

Thanks to everyone for helping me get this sorted. I also feel like I know WP and PHP a little better now :)

Cheers

Ben



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum