Hello
I am using Custom Post Type Templates for single pages on my website, but instead of creating a file for the template (single-{post_type}.php) I would like to have the contents populated from a plugin.
- Please can you help me by linking to any resources that detail how to do this
- If appropriate, quote for how much you would charge to complete this work (basic implementation)
Hariprasad Vijayan answers:
Hi,
Check this link
http://wp.tutsplus.com/tutorials/plugins/a-guide-to-wordpress-custom-post-types-creation-display-and-meta-boxes/
Hope it will help you. please ask if you have any doubt in this.
npeplow comments:
Hi Hariprasad
That post details how creating a file for the template "Step 3: Create the Single Page Template File", what I want is for this "file" to be populated from a plugin function. This would allow me to switch between themes without having to recreate it
Thanks
Nick
Hariprasad Vijayan comments:
Hop that will solve your issue. Please ask if you need anything further.
Good luck Nick
npeplow comments:
Hi Hariprasad. It does not solve me issue, I *do not* want to use a template file - instead I want a function in a plugin to handle that.
Krum Cheshmedjiev answers:
Hello,
There is possible to make a dummy "single-{post_type}.php" with content like:
<?php your_functiuon_in_your_plugin('post_type'); ?>
Then in your plugin you can create just anything. Note that this is a template file, so result has to be recognized as template. This way single function in your plugin can server lots of post types. But I would make a function for each type - easier to debug.
npeplow comments:
Hi Krum
Thanks for the response! If I understand you correctly, your suggestion still seems to include creating an actual file, which is something that would not work for me.
Krum Cheshmedjiev comments:
You car run your function from "single.php", "heared.php", "footer.php"...
Krum Cheshmedjiev comments:
Sorry, "header.php", not "heared.php"...
@Admins: Why no way to correct it here?
Remy answers:
Do you want to bypass the theme and template system completely ? Because even for a CPT, if you have a index.php and style.css files in your theme, it'll display it
npeplow comments:
Hi Remy
This is how I understand wordpress works - when a user visits a page that's set to a custom post type, it looks for a template with the format single-{post_type}.php , this loads via includes the header, footer etc. As I plan to use a number of themes, I dont want to have to create this file for each template - so I would like the functionality of single-{post_type}.php but in a function
This is the closest example that I think may word
http://stackoverflow.com/questions/12928273/is-it-possible-to-make-a-custom-page-in-buddypress
npeplow comments:
Apologies, incorrect link above - it should be http://webstartavenue.com/ultimate-wordpress-development-guide/how-to-create-a-wordpress-virtual-page.html
Remy comments:
Would it be ok if you created the template file in your plugin directory, and not in the theme directory ? This can work in WordPress too, and you would have the same file whatever the theme is