0

I am sure this has probably been asked before, but I've tried all sorts of searches and cannot find a definitive answer. Maybe it's just not possible!

I have a directory of users (displayed using an "agents.php" template).

URL: /agents

When you click on an agent, it goes to another page, "agent profile" which uses profile.php

URL: /agents/profile/22

Using some rewrite rules I can access the query var 22 and can use that.

I now how ever want to re-write the page title and meta descriptions based on the current agent. So the webpage /agents/profile/22 would have a title of "Viewing agent 22" for example. If you view agent 23 it would then change the page title to "Viewing agent 23".

How can I do this from within the template? I've created various hooks in my functions file, but I obviously cannot access these at the page template level. I'd rather not have a different header for just this page if possible.

Any ideas? I am totally stuck!!

0

An Alternate Solution is :-

You can make a form and when click on link submit the form with post request by JavaScript or jquery and send user id with post method in hidden field and get it on profile page get the user data by id and display it where you want.

  • I wanted to know if it's possible to alter the meta title and description from within the template? – A Sinclair Apr 4 '17 at 11:23
  • yes we can alter the data from template by update post meta by meta key and post id – Abhishek Pandey Apr 4 '17 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.