I'm new to wordpress plug-in development.
I want to create one plug in. the functionality of plug-in is
# it will catch url like, www.example.com/custom_post_type/param1/parm2/parm3
param1,param2,param3 are parameters passed to custom_post_type.
# i need to catch these parameters and want to communicate to database accordingly i want to show page content.
i don't know whether i should use custom_post_type.(because i'll use self made tables to check for parameters)
please suggest me.
What you need is the Wordpress Rewrite API. You can get more information about this at the Wordpress Codex
Tutsplus has an great article about using the Rewrite API: The Rewrite API: The Basics
First, you have to validate if you can achieve efficiently what you want to do with Custom Post Type. You do not give enough details to be able to tell you if it would be better, in this particular case, to use CPT or build custom tables. That said, most of the time, you can use both: CPT mixed with custom tables.
As for your URL question, you need to play with the: Rewrite API. This will enable you to manage the URLs the way you want.
Unfortunately, the Codex may be hard to understand. Fortunately, you can check this great resource where Carl Alexander explains exactly how it works: WordPress for the Adventurous : Rewrite API.
Another possibility is to breakdown the URL by using the variable $_SERVER['REQUEST_URI']. That said, I would avoid this option if possible. Using the rewrite API is the proper way to go.
Related
I am trying to create a Google Form for a project and I was wondering if it is possible to have a custom domain or URL for the form. I know that the default URL for a Google Form is something like forms.google.com/form/xyz, but I was hoping to have something like myproject.com/form instead. Is this possible, and if so, how can I set it up?
Any help or guidance on this would be greatly appreciated. Thank you!
Yes, it's possible to have a custom URL. Google provides a way of shortening the URL but it's still not in a readable format. But it seems like you are looking for a way to embed or integrate google forms into another domain with a custom URL. There are great solutions already available for it. I would recommend you to check out BetterCollected. They not only provide the possibility of adding a custom URL to your forms, but if you work in an organization, you can create custom workspaces. You can even have a custom domain if you intend to without any hassles.
So I have a local website that I am developing and I was wondering if there is a way to create a blog functionality without creating a database and by using HTML5/CSS alone.
From searches around it doesnt seem possible, so maybe if I could embed the blog functionality from somewhere? i.e a blogging service that would allow my users to use my website but they are posting to a database somewhere else?
If I could do that, could you give me an example and what would be the method on doing it?
Thnanks
I actually haven't tried this yet, but you could have a look at http://developer.wordpress.com/, particularly in the API section. For example, if you look at the GET /sites/$site/posts/ API, the doc summary says:
Get a list of matching posts.
So one may use a query matching the pattern:
https://public-api.wordpress.com/rest/v1.1/sites/en.blog.wordpress.com/posts/?number=2
To obtain, in response, quoting the doc page, three parameters:
found (int), the total number of posts found that match the request
posts (array), an array of post objects.
meta (object), meta data
So you may create a free and simple blog on wordpress.com and access its post via the above mentioned APIs. Therefore, you won't require any database on your local site.
Still, some simple PHP, or maybe Javascript is required, but I really can't imagine how one could avoid preprocessing in any non static website, as a blog is. For example, you may use simple GET requests to use the APIs (see this doc as an example of how to do it).
I'm trying to understand how URL Mapping works. I've gone through numerous pages, but I can't seem to wrap my head around what I'm trying to do.
Its really simple, I use DataObjects as pages approach and I have a member extension written to the member class. And I have the typical actions, show, edit, add.
So if I go to www.mywebsite.com/members/show/1 I can see the first user. If I change show to edit, I can edit the first user. Now if I go to www.mywebsite.com/members/add I can create a new user. This is working all as expected due to the functionality I created in the add method.
My problem is in the fact that when you go any website, you don't register to the website by going to members/add, you register by going to website.com/Register or something similar. From code management perspective, it is a lot easier for me to leave the code the way it is now. I don't want to have to create a Register page and move the code there, instead I am trying to figure out if it is possible to go to www.mywebsite.com/Register and have it load www.mywebsite.com/members/add. I am not talking about a redirect link that would update the url, I want users to still see Register in the url and not see /members/add.
Vice versa, if users were to go to www.mywebsite.com/members/add I want the link to update to Register or say page not found.
Is this possible with Silverstripe Framework?
I am not 100% sure, but I believe this is called URL Masking.
This is very possible, firstly I'd advise that you look over...
silverstripe-memberprofiles
...because even if you dont' want to use an existing module I'm sure there would be useful information. There is a great example of "pure" routing (i.e. silverstripe no cms) that leads on to "nested" routes - which is what I think you are asking for, so I highly recommend reading the slides below and then the created todo app
silverstripe-framework-building-without-the-cms
todo app source
I work on a shop using WordPress and a discontinued (but still used) shopping plugin/theme.
The frontend search was never very good, even after some alterations to the way the search query is built. A fulltext index did help a bit, but it largely fails now, because there are many (almost) three-letter product names like t-700 / 700.
In the backend products search (must be a custom post type) however, the search is fine. It is just what the shop owner wants.
The perfect thing would be to bring just this backend search to the frontend, either by calling the right function / hook or by copying the relevant code.
The code structure pointed me to wp-includes/query.php, but there I failed to understand how backend queries work. I've been searching the web for days now and I just can't find anything at all.
Any help or suggestions are greatly appreciated. Thanks a lot!
What you are using on frontend ? you must use query_posts for all posts on frontend as it gives option to pass all possible arguments in it.
You can check this link for reference
We need some more informations to help you! Without knowing the plugin you use or at least what's in the query.php it's impossible to help you.
The code for this search tool is specific so nobody can tell you how to get it to work in your frontend.
Usually I'd try to copy it into a frontend page (or try to call it there) but that might be a risk! Backend and frontend data should have different access rights, this might be the reason why you can't just copy&paste the function.
I want to translate my ASP.NET website, just like microsoft does.
I want the urls to have /en-EN/ or /de-DE/
the problem is that my urls ar already routed URLs
How can I do this?
I found this http://blog.maartenballiauw.be/post/2010/01/26/Translating-routes-(ASPNET-MVC-and-Webforms).aspx
but I don't want to translate all the urls and this method seems to me too complex, with Views and Controllers.
I need mysite.com/en-EN/routedpage or mysite.com/de-DE/routedpage
The above example is for mvc, is your website in mvc?. You need to setup your website for culture specific setting, here is an article how to do that
http://www.ezzylearning.com/tutorial.aspx?tid=3477182
Also for further reading
http://www.codeproject.com/Articles/7998/Creating-multilingual-websites-Part-1
and
http://www.codeproject.com/Articles/8073/Create-multilingual-web-pages-very-easily
its very easy to setup
This is an important problem. You want the URL to have the language encoded in it for both SEO and usability purposes.
Two common solutions are:
1) Change the domain. fr.example.com or de.example.com. Then the routes don't need to be changed.
2) Use the # for the language code. Search engines nowadays will observe this. So, then you'd have www.example.com/#de or www.example.com/#fr
You can implement both of these solutions with www.SiteTran.com by simply pasting our javascript into your page and setting the sitetran_url_type variable to either:
var sitetran_url_type = 'sub.domain';
or
var sitetran_url_type = 'hash';
SiteTran is 100% free and is my company.