Wordpress permalink to allow title variable in - php

So I built a site (In the wrong way which I can see now).
Users can post ads, they are not stored as a post, I just store the information in a table in the database.
I use a page template with parameters passed in - For example www.site/ad/?id=1&cid=2
id = id from database
cid = category id from database
I then use a wordpress page, pull params from url and load all information from DB relating to the id and category id.
In the wordpress admin there is a page set - the page uses an ad detail template for all urls that are www.site/ad/?
What I want to do now is put the ad title in the url so www.site/ad/adtitle/?id=1&cid=2
The issues with this is the page will not load as the permalink now does not correspond
perma link is www.site/ad/?
so cannot use www.site/ad/adtitle/? and still load the page with template.
I guess the question is can I make so that the page will load the url with the ad title in
I try to set permalinks to allow custom structure but no luck
Apologies about title didn't know what to call this

Fixed it with pods, which will allow you to use a page referencing a part of a url
http://blog.stefanxo.com/2014/02/how-to-create-a-pods-page/
Thanks

Related

How to change a URL for a specific page in WordPress?

I'm not talking about site URL.
I mean like changing from mysite.com/our-team/john-doe to mysite.com/our-volunteers/john-doe
I just want to rename the /our-team/ to /our-volunteers/. There's only one john-doe page. Now, John Doe is NOT our team per se, but he's a volunteer. So, I need to change the slug to "our volunteers."
The current premium I'm using does not create a WordPress typical page for this so I can't modify the url of the page. So, this does not work -> https://www.competethemes.com/blog/change-page-url-wordpress/
Is there like a hook i can use? Permalinks only allow changing the url structure of the entire site.
What you exactly looking for is Page attributes
https://wordpress.com/support/pages/page-options/#parent-page
You have parent page Our volunteers
http://example.com/our-volunteers
And pages of children pages
http://example.com/our-volunteers/john-doe
http://example.com/our-volunteers/foo
http://example.com/our-volunteers/bar
Set our-volunteers as page slug when you create Our volunteers page
Assign pages John doe, foo, bar to Parent page (Our volunteers) from Page attributes section bottom right on 'creating new page' page
One hack could be to edit .htaccess for this particular issue. It's kinda hacky and might get you into other problems. There's also plugins to do rewrites for you.

How to add a description in the CMS for the posts index.php file in wordpress

I need to add a custom field in the admin for the posts page.
I'm currently pointing the reading post pages to my index.php file and I haven't got the usual input fields that you would find in a template. I am just left with a featured image and a title.
The question is how would I go about adding a field to this page in the admin so I can print it out in the index file?
It is worth pointing out that I am currently using custom advanced fields if this help towards my solution.
Ta
So people can use this thread in the future I found a solution to my problem.
When you set the reading of post pages to a certain page it no longer becomes a page. This means that you have to access it in a different way which I was unaware of.
If you wish to access the data that is on the posts page then you have to use the below php:
$page_for_posts = get_option( 'page_for_posts' );
This allows you to check for the ID on the page for posts which is the same page as mine.
Then if I want to get the title of that page I can do something like this in my php file:
<?php echo get_the_title($page_for_posts); ?>
And if you are using custom advanced fields which I am then you can put in a second parameter like so:
<?php the_field('blog-introduction', $page_for_posts); ?>
Many thanks

Magento 301's with PHP code aquire Seo Url?

I am looking to migrate a website from Cubecart 4 to Magento 1.8. I have created a script that grabs the old cat id from the url, then searches the database to where this is stored (I copied them over) It then grabs the new magento category ID and then needs to grabs the URL of that category. I then want to make a 301 redirect from to the new url.
I cant grab the SEO url from the ID however. So far I can grab the un written url from the id with this where $caturl2 is the category id.
Mage::getModel("catalog/category")->load($caturl2)->getUrl();
Is there anyway to grab the seo url by ID? Any ideas?
At the minute it's outputting: /catalog/category/view/s/cat-name/id/4448/
To get the full SEO url, stored in URL rewrite management tables, you should use the follwing code.
Mage::getModel("catalog/category")->load($caturl2)->getUrlPath();

Wordpress - create a page with custom URL

I have a Wordpress page /users and it displays a list of all users created. Each user has a link to its profile page. What I need to do is create that page. I want it to go like this /users/{user_id}-{first_name}-{last_name}, for example - /users/1-john-doe. I have a template for /users and also for profile pages. Question - how do I properly make a page with that profile template so that it would have the url described above? The page does not need to select the user automatically, it needs to pass the user slug so I can read it in that page and query for that user (as a variable or something).
Thanks.
What you are looking for is the WordPress Rewrite API.
This allows you to define a new "endpoint" for your URL's, and allows you to pick up the variable from the URL via built-in WordPress functionality.
A great article on it can be found here: Custom Endpoints

Wordpress Author Link 404

On a search page I allow the user to click a on the authors name to view all posts by that author. Im trying to create the link to the authors page but I keep getting 404’s. However the admin user works. I have checked the user types and they are set authors (Admin is administrator).
Code Example
get_author_posts_url(get_the_author_ID());
Result
This returns "/author/tester/" which looks correct since the admin one "/author/admin/" works. However clicking the link goes to 404.
Notes
This code is executed in a Wordpress loop.
User type is Author.
Ideally I would like to use the users nickname/display name not actual.
Try :
get_author_posts_url( $author->ID )
Also since you're using it within the loop, try without any ID :
get_author_posts_url()

Categories