How to add custom URLs to my WordPress template files? - wordpress

I'm developing a WordPress theme and I need to have a custom URL for some kind of content.
For example, I need to have a page to show some article details. Now, i've created a page template called "Article", and so i've to create a new page and give it the page template "Article"
(I get the url http://mydomain.com/article?id=123)
It works fine, but now i'm having dozens of this pages, and it's a mess to create them all on every installation of this theme, so i want to do it in my theme code.
I saw something near that on BuddyPress, where you can use /member/ and it redirects to a member page. I just wanna know how to do so.
Thanks!

If you are running wordpress 3.0 I would recommend making a custom post type for your articles. That would allow you to control the URL in the way that you want and also allow you to use more sophisticated full text urls if you wanted to.
Here are some links to some tutorials about how to make a custom post type to get you started:
http://kovshenin.com/archives/custom-post-types-in-wordpress-3-0
http://kovshenin.com/archives/extending-custom-post-types-in-wordpress-3-0/
The second one has an example file that you can download and edit to help you get started.
Cheers,
Paul

Related

Wordpress multilanguage URL

I'm building my own theme in WordPress, and the website will be in multiple languages.
All I need is to find a way to assign a language to each page, and this language should be added to the URL as well. (I'm guessing adding a taxonomy, but I'm not sure how to add this to the URL)
I will create a different template page per individual page. Most plugins try to translate each page, this I don't need.
Lastly, of course, I will create a separate menu per language, but these links should link to the correct page URL (with the ../language/..)?
Is there a way/ plugin that can help me do this?
Thanks a lot to all who can help me with this!

Wordpress Custom Fields for og:image

I am building a website in Wordpress and I am writing some Articles. When I share my post/article on Facebook, the wrong image appears (on the phone, as on the computer it seems that the image is chosen correctly). I have seen that Facebook needs the og:image tag and it needs to be called in the head metadata. As I do not have many options to add metadata to the page, I felt like using the Custom Fileds in Wordpress as being the cleanest way. As I am new to this and I am not sure I did it correctly, please guide me on how to call these custom fileds to the head metadata part of my page when it loads. I have attached a snip of my custom field here:
custom custom field
Please let me know if my thinking was correct or if I should use another method to accomplish this.
Thank you very much.

How do I call a plugin in a custom page for wordpress?

So I am trying to do this and I don't know how. I have a wordpress powered website with a plugin called "frontier-post" in it. This plugin makes a new front-end post submission. The way to use it is to put the shortcode "[frontier-post]" in any post in my wordpress page and that page turns into this.
I want to make a custom page for myself, where I can have the content created by this plugin there too. So I do not want it to be a post in my wordpress, but lets say at a corner in the custom page. I have searched and found these but the suggestions there would not work. I am able to include the wordpress so that the custom page has access to posts, etc. but even using this
echo do_shortcode('[frontier-post]');
would not help me. (even if header is included)
These are the similar things i found:
Wordpress/PHP - How to use plugins outside wordpress-powered pages?
Need Help for my Custom Page Template
I would really appreciate it if you could help me with this.
If you are creating a PHP page that isn't going to be rendered inside WordPress, you can't use a Plugin of the WordPress engine to accomplish what you are wanting to build. (As the accepted answer to one of the pages you link to indicates).
Instead, you might be able to use the json-api plugin and have your custom page query it for the data. While it won't render the shortcode, it will give you the raw data to work with.
http://wordpress.org/plugins/json-api/
Edit:
Based on a comment, your do_shortcode should work...just try it without the square brackets.

Wordpress Not Publishing Posts To Custom Template

I am building a theme that has a lot of custom templates, like every page. Ridiculous, but for some reason the template I made for the "postings" page is not getting the posts? I have set the post page in reading preferences, and I have set the page to use my template, but it still publishes posts to a default template. Of all the customization I built into this I did not expect the blog part to give me trouble! lol Anyone run into this kind of thing?
Thank you.
The way I usually to it is to have standard setting in reading preferences.
Build my front-page in index.php
Build a template for blog posts
Add a page and assign the blog post template
Of course you then have a kind of placeholder page sitting amongst the other pages, don't really like that. But it works.

Post pages in Wordpress 2.9

I'm trying to use a posts page in Wordpress. For the uninitiated, this is a page (other than the home page) which features all your blog posts. You essentially turn on the static home page and point Wordpress at a custom index. Then you tell Wordpress to use another custom template as your "posts page"; thereafter, any post you make will wind up there.
My custom template for the 'Blog' page shows up as expected until I define it as the posts page. When I do, the template reverts to my custom index and I get no posts. When I undefine it as the posts page, it goes back to my template. What am I missing? I'm new to using this method, as it used to be done with a plugin prior to WP 2.9
So, I figured out the solution and wanted to share. Thanks for all your input, everyone.
The problem was with the name I chose for the template. I had called it "blog.php", which works fine when creating an ordinary page template. But when using a page as a posts page, Wordpress has some specific setup rules. The pertinent section of documentation, which I scoured the entire internet for using hours of my life I'll never get back, is hidden here:
Also, any Template assigned the Page will be ignored and the theme's index.php (or home.php if it exists) will control the display of the posts. (from here).
So, I named my template "home.php", since I wasn't using a home.php in this particular install, and I was off to the races. Anyway, thanks for the answers!
BTW, I think this may have been what Richard M was getting at.
Your problem might be in creating "templates" and the single post (single.php) You can create a template for any of your pages by putting this in the top of your page (after the first < ? php:
/**Template Name: ****templatenamehere**** #package WordPress * #subpackage Default_Theme */
...rest of code
This allows you to create a page called "posts" which references your new template. This way you can create a new template and then call it through a page. If this is confusing or you have tried this let me know and I will try to give you more details if you need. Thanks

Resources