I would like to know the best method for layering posts in wordpress 3.0 when you need to swap back and forth between structure and data. For example, custom post type 1 has 6 custom fields, each field contains a value for the tab shortcode; i.e. [tab:data] [tab:credits] [tab:where to buy] etc - this type is standard every time the page is called and always the same post; then it needs to switch to another custom post type and select the data post it's going to use based on what tag page is being called. Then it needs to pump a custom field from data post into the same display space as the base structure post, and then hop back and forth between structure and data, and THEN run a loop. Thanks in advance.
I would just query for the two special posts before you do the loop, with get_posts (which will not mess up the regular query). Then you can display them however you want, with their information mixed together, and then do the loop.
In this example, $fixed_post is a fixed post with slug "fixed_post_slug" of the custom post type "fixed_posts". $tag_post is a post where the name equals the current tag (if we are showing a tag page), and of custom post type "tag_posts".
$fixed_post = get_posts(array('name' => 'fixed_post_slug', 'type' => 'fixed_posts'));
if ($fixed_post) {
$fixed_post = $fixed_post[0]
}
$tag_post = get_posts(array('name' => get_query_var('tag'), 'type' => 'tag_posts'));
if ($tag_post) {
$tag_post = $tag_post[0];
}
Related
Within the array for a custom post type named rg_story that I am defining, I have the following statement:
'chronological' => true,
Later, I have this:
if ( 'rg_story' == get_post_type()) {
As far as I know, everything is working OK. I'll know for sure once I create my templates. This is my first time with this stuff.
The problem is that I would like to test for the value of 'chronological', rather than the specific post type. I'm just not sure which function would do that.
I am trying to fetch previous and next custom post type link from same taxonomy within single-custom-post-type file
As per codex passing 5th parameter i.e. taxonomy name http://codex.wordpress.org/Function_Reference/previous_post_link should make it work
Here is my code
previous_post_link('%link', 'Previous Case', TRUE,'',$taxonomy)
previous_post_link('%link', 'Previous Case', TRUE,'','custom_categories')
I have tried both way i.e. passing dynamic variable as well as string, yet I cannot get it to work, What it returns is random custom post type links rather than from same category
the code is bit long so I have pasted it over pastebin http://pastebin.com/X5pKuifA
The above code works perfectly as mentioned in codex, The issue turns out to be I have allocated 2 categories mistakenly to all of the custom post type thus the pagination within same taxonomy was not working.
So If you land on this question make sure you donot have more than 1 category assigned to your posts
I'm writing a file management plugin that uses the category system to create a mock filesystem hierarchy and I'm running into some issues with some code that is responsible for recursively deleting the 'folders' (actually categories). Instead of the code returning all of the child categories of the category to be deleted, it returns an empty array. Any ideas why?
//get all child categories
$wk_child_categories = get_categories(array('child_of' => $_POST['wk_ID'], 'orderby' => 'term_group'));
echo " Got the child categories. They are:";
print_r($wk_child_categories);
One thing that I can see that might be causing the issue is the lack of the post parameter. By default if you don't have a post parameter it will fallback to the standard Wordpress "post" type. If you are using a custom post type it would return an empty array because the query is looking in the wrong spot.
There is also the possibility that the categories are empty. In the arguments for get_categories() there is a hide_empty argument that will default to not return empty categories, try setting that to 0
I'm working on a website that uses Domain Access and for a view I expose a filter that lists all domains. I want to list only some domains but not all. I know that it is posible to do with the filter configuration, but if I limit the options this way there is a problem with ajax which changes all the options text to "1", and in any case I want to know how to do it, with either hook form alter or with themes, but preferably using some hook from a module.
In general I'm trying to figure out how to remove some of the options for an exposed filter, I managed to do it using JQuery, but I'd like to do it with php, thanks!
It should be fairly straight forward using hook_form_FORM_ID_alter as you suggest. First inspect the <form> element of the filter form (using Firebug or similar) and get it's ID attribute. The form's ID in Drupal will be that string but with all '-' characters replaced with '_' (so 'form-exposed-filter-form' would become 'form_exposed_filter_form').
The thing to remember is that the submit handler for the form will probably be expecting the elements you're trying to remove to be there, so you'll probably get unexpected results if you just yank them out of there.
The way round it is to change the type of the elements to value instead (so they're available to the submit function in $form_state['values']), and choose a default value for each. Something like this:
// Replace 'FILTER_FORM_ID' with the form's ID
function mymodule_form_FILTER_FORM_ID_alter(&$form, &$form_state, $form_id) {
$form['some_existing_element'] = array(
'#type' => 'value',
'#value' => $default_value_for_filter
);
}
I have written a wordpress plugin that uses jqgrid. When I submit one of the rows in the jqgrid to be saved, the names in my table columns (like "name") are conflicting with the wordpress query vars and causing a 404 to be returned.
Is there any way to get the jqgrid post to be wrapped in another object, so it's not posting the raw query var "name" to the server? Can it post something like
$_POST = array(
'jqgrid' = array('oper' => 'add', 'name' => 'whatever')
);
instead of
$_POST = array('oper' => 'add', 'name' => 'whatever');
?
jqGrid has prmNames option which can be used to rename any of the parameters used in URL or POST by jqGrid. For example default value for the "add" operation are defined by addoper:"add".
I don't understand what you mean under the "name" parameter. the column name are not used as the name of any parameter which are posted. If you have the problem because of the usage of toolbar searching I would recommend you to use stringResult:true option which makes information about the searching in the same format like in case of the usage of advanced searching. If you describe the problem more detailed I am sure that I could help you.
UPDATED: You can use serializeEditData (for form editing), serializeRowData (for inline editing) or serializeCellData (for cell editing) to convert in any way the data which will be send to the server during Edit/Add operation.