Custom Pods.io detail page - wordpress

I am attempting to create a custom template page for a details page for my Pods.io 'research_faculty' pod.
I have the url going currently to /people/details and it does go to that page but I created a 'details' page that I have assigned a custom template to display the information that I want. Problem I am having is that its treating the last part of the URL as a page and Wordpress is saying page cannot be found. So it would be /people/details/wally-kolcz. How can I use the past part of the URL as the way to pull the person's details and populate the template page rather than WordPress trying to use it as another page and defaulting to the single.php template?
Pod (Advanced Options)
Custom Rewrite Slug: people/details

You can use pods_v( 'last, 'url' ); to get the last segment of the url. If you put that in a variable you can use it to build your Pods object.
// get current item
$slug = pods_v( 'last', 'url' );
// get pods object for current item
$pods = pods( 'pod_name', $slug );
See this tutorial for more information: http://pods.io/tutorials/using-pods-pages-advanced-content-types/

Um create a pods page and on the Enter page URL section enter /people/details/* so that it responds to /people/details/+ anything. Also in the slug section u can try putting {#url,2} If it doesnt work. Also go to the advanced options of your advanced content type and in the detailed page URL enter pod_name/{#permalink} though that may not be necessary but try that and test it again.Make sure the pods page also has a pod to refer to and that it points at your php details template

Related

Custom post type: creating a page template with the same slug

I'm currently working on a custom post type and want to be able to edit the archive page from Wordpress with a page template. So I created the CPT called 'cars' and created a page template with template name: 'Cars overview'. Next i create a page inside WordPress and choose the template page 'Cars overview' and gave it the URL: mywebsite.com/cars/
Now the problem is that the slug 'mywebsite.com/cars/' is already in use by the custom post type itself causing the page to load the custom post type loop instead of the page template loop. So I can't edit the title, content etc inside WordPress. I could change the url of the page, but i want to be able to control the overview page in WordPress.
Long story short: How can I create a page template that is using the same URL as the custom post type archive page?
Thanks in advance!
One simple solution, simply disable the archive where you create your custom post type:
register_post_type("cars", array("has_archive" => false));
Another approach rather then disabling the archiving and adding another page to show the cars. Changing the archive template used by your theme might be a better option.
First step is to find the template currently in use by your theme, copy it to your plugin file and you can change the template file to whatever you like. You can find more information about it here.
The only thing you need to do is point WordPress to the right direction:
add_filter("archive_template", "archive_template");
function archive_template($archive_template) {
global $post;
if ($post->post_type == "cars")
{
$archive_template = "path/to/your/template.php";
}
return $archive_template;
}
Disabling the archive and creating one manually seems a bit strange to me. And I always replace the archive page and sometimes single page from our theme (usually the7).

Wordpress - How can I create my own template outside of the expected hierarchy of templates and feed a query to it?

BACKGROUND
I have used WordPress custom post types to create a newsletter section for my website. Newsletters consist of Articles (dm_article), which are grouped by the Issues taxonomy (dm_issues).
1) I have created an index of all of my newsletter Articles. I am using a template called taxonomy-dm_issues.php to loop within a selected Issue and display each Article's title, excerpt and a link to the full content, which is managed by single-dm_article.php. This is working great.
2) I would also like to create second taxonomy-based template for Issues. This is going to act as a print-friendly option: "print entire newsletter". I would like the template to loop through and display each Article title, excerpt, and long description. Some of the look and feel will also be different.
For #2, let's assume I've created a template called print-dm_issues.php. It currently looks identical to taxonomy-dm_issues.php, except it has the additional long description data for each Article and contains some different styling.
I want to setup this "print friendly" option without making the WordPress admin have to jump through any hoops when Issues and Articles are created. I also do not want to have to create a new template each time a new Issue is created.
CORE QUESTION:
What I am asking for may boil down to this: How can I create my own WordPress template outside of the expected hierarchy of templates and feed a query to it? Do note I am using the "month and name" common permalink structure, so I'll have to muck with my htaccess.
ALTERNATIVES:
1) My fallback is to have taxonomy-dm_issues.php contain the information for both variations and use style to handle the different view states. I know how to do this. But, I'd rather not do this for sake of load times.
2) Using Ajax to fetch all of the Article long descriptions (the_content()) with a single click is an option, but I don't know how.
3) ???
With or without clean URLs, you can pass variables based on your taxonomies through the links query string if you want to only return a single taxonomy term and style the page differently depending on the term.
$taxonomyTerm = $_GET['dm_issues'];
$args=array(
'post_type' => 'dm_article',
'dm_issues' => $taxonomyTerm,
'post_status' => 'publish',
);
There is reference to this int he Wordpress 'query_posts' documentation by passing variable into your query parameters: http://codex.wordpress.org/Function_Reference/query_posts#Example_4
For instance in the link below, the title is generated based on the sting in the URL.
http://lph.biz/areas-we-serve/service-region/?region=Conestoga
You can set up a parameter that will return a default value if the page is reached without the variable being defined. See below:
if (empty($taxonomyTerm)) {
$taxonomyTerm = 'Default Value';
}
You can create a separate page template. Define the template name at the top of your PHP document:
<?php
/*
Template Name: Printed Page Template
*/
Place your custom query, including all of the content that you need output in this page template... In your WP admin, create a new blank page and assign your new 'Printed Page Template' template to this page. Save it and view the page.

WordPress - Custom Post Type Entry Won't Load Into A Page

I created a very basic custom post type in my WP site to hold events. Basically, a user can input an event title, some information about the event and the date.
Currently, the only time the events are being displayed are in my sidebar where I just pull the title and date of the upcoming events.
However, I want to be able to allow the user to also click on the title of the link to lead to the event's individual page. I tried previewing my custom post type event and it kept leading me to my 404.php page. The events don't seem to load into a page at all.
I'm hoping this is a small property that I didn't set when I registered my post type. Any help?
Wordpress has incorporated custom post types into the template hierarchy and you have access to them at single-$posttype.php and archive-$posttype.php.
If you create these templates and your posts don't show up in the loop, you need to reset your permalinks/flush your rewrite rules.
As well, it would help to see how you are registering your post types, as in order for your archive-$posttype.php to be available you need to call has_archive => true in your arguments.
What i've done when i needed it:
Add this code in the same function that create your post type:
add_action("template_redirect", array(&$this, 'template_redirect'));
function template_redirect() {
global $wp;
if ($wp->query_vars["post_type"] == "events")
{
include(TEMPLATEPATH . "/events.php");
die();
}
}
Then, just create events.php with the_loop (like single.php)!
Hope it helps
[]'s

How to get $_REQUEST[] through URL in wordpress

Hi I have a problem in my site on which am working on localhost. I am using pretty urls in my localhost.I have custom page templates for all the sites every page has a different header and footer and the content in it.
I used
<div class="btn_container"></div>
<div class="btn_container"></div>
The Problem I have to get request parameters in wordpress and query the db against these request query string parameters. And also it does not route to this page template.
I have hard-coded URL like in the above divs.
Please help
Could you simply grab the link id from the URL like
$link_id = $_GET['page_id']; // this would equal 1038 from your example link
A page template is assigned to the page through the admin panel:
1. Go to the admin panel
2. click on pages
3. choose the page you have created
4. choose the template on the right hand side.
Simply linking to it does not assign the template to the page like your example is showing.
Try
$pageId = get_query_var( 'page_id', 0 );
get_query_var() only retrieves public query variables that are recognized by WP_Query.
This will not work with your custom variables.
If you want to get your custom variable check wordpress documentation - https://codex.wordpress.org/Function_Reference/get_query_var

WordPress add a new page to admin section

I have already developed my plugin for WordPress and I can manage it from admin. I have passed the access to the plugin file using add_submenu_page. The problem is that the plugin is extending and I want to use another file that is linked from the main file. For example I have second_page.php?id=3. When I try to access this link, I get a
You do not have sufficient permissions to access this page.
message. I want to "validate" this page also for using with this script and I don't know how. Ideas?
When you add a page with add_submenu_page(), the url should be something like:
wp-admin/admin.php?page=<your_page_handle>
Your page is actually loaded from admin.php (typically). You can add parameters to your links by appending something like &id=3 and then have your main plugin page-loading logic determine which file to include based on the parameter.
For instance
if (isset($_GET['id']) && ((int) $_GET['id']) == 3) {
include 'second_page.php';
} else {
include 'first_page.php';
}
Edit:
I found a trick that may be easier for you, though I haven't thoroughly tested it. Let's say that you have two pages: my_one and my_two. Just call add_submenu_page twice, and set the second page's parent as the first page. This will cause Wordpress to not add a link to the navigation bar, but you can still access your page by navigating to admin.php?page=my_two.
Example:
add_submenu_page(
'my_toplevel_link'
, 'Page Title'
, 'Link Name'
, 'administrator'
, 'my_one' // here's the page handle for page one
, 'my_one_callback'
);
add_submenu_page(
'my_one' // set the parent to your first page and it wont appear
, 'Page Title'
, 'Link Name' // unused
, 'administrator'
, 'my_two'
, 'my_two_callback'
);
Since WP natively supports URLs like wp-admin/admin.php?page=<your_page_handle> you can do sub pages with something like:
wp-admin/admin.php?page=yourpage
wp-admin/admin.php?page=yourpage&sub=2
wp-admin/admin.php?page=yourpage&sub=3
Then in the code that handles wp-admin/admin.php?page=<your_page_handle> you just look at the $_GET and pull up the main page or a sub-page as needed.
I've definitely seen plugins where the admin page has a little row of links across the top linking the various sub-pages.

Resources