Order wordpress post by custom field value? - wordpress

Currently i have tried half internet codes ( :D ) to make this work, but with no luck.
I'm not a wordpress guru so it's quite bit hard. Basically what i want is to make plugin that will alter all post ordering across all wordpress blog based on date value in custom field.
For example i add custom field to each post (meta_key=bb_history) and (meta_value=2011-04-03).
So where i would hook or what filter should i use to get this working somehow? I guess you can use posts_where, posts_join, posts_orderby actions to make something?

You don't want a plug-in. Just edit your query_posts statement in the template in question.
query_posts($query_string . '&meta_key=YOURFIELDNAME');

Related

How to insert a custom post field in a Wordpress Pod?

I recently started using the Wordpress Pods plugin and I'm trying to insert a custom post field in the Pod.
It is not working. Is there any way to do this?
I have created a pod named "network-section"
This pods works:
[pods name="network-section" where="id = '4'"]
[/pods]
However, I want to use the {#network} field because I have a lot of posts with different network categories.
This is not working:
[pods name="network-section" where="id = {#network}"]
[/pods]
{#network}"] is a custom post field.
Thanks!
your shortcode won't work like that I'm afraid. The ID field is looking for an integer that corresponds to the unique ID of a certain post. That's why your first example works but second one doesn't.
If you want to have a sub-selection of network-section posts, you should find a different way to select them instead of using 'ID" ,(which, by definition, will pull at max only one post).
For instance, you could add a custom taxonomy and use that to filter by in the shortcode, or sooner other field.
The easiest solution might be too create a field in your Post called "network category" then door each of your posts you can give them a particular number.
That way, in your shortcode, you can do:
[pods name="network-section" where="network-category.meta_value = '2'"][/pods]
N.B. you will probably need to use that ".meta_value" to get the right bake in your shortcode, but it depends on how you sweet it up. AND you'll need also need to add your html and other code somewhere (can be in a Pods template or even between shortcode open and close tags) otherwise there will be nothing to display...
Good luck!

how can i create archives for custom post type

the WordPress framework allows to build different archive templates for each of your custom post type by e.g:
archive-event.php
taxonomy-event_category.php
is it possible to create author and date archive for custom post type by doing the following:
author-event.php
date-event.php
if this is not possible, can anyone advise how i can go about achieving this?
I think these links will help answer your question and get you started:
http://codex.wordpress.org/Template_Hierarchy
http://codex.wordpress.org/Category_Templates
The gist of it is that you can in fact make an author-event.php however date-event.php does not get checked because the template hierarchy dictates that it uses date.php, archive.php, or index.php.
One solution is to use conditional tags such as is_author() or is_date(). If you do, keep in mind that you'll have to have a common archive.php and decide which template you really want to use by using conditional tags.

Advanced Custom Fields not saving at all now

I downloaded and installed Advanced Custom Fields 4.1.6 the other day and I used it a few times for some time and it worked perfectly, but for some reason now none of my custom fields seem to be saving and I'm not getting any errors or anything. I don't think that I have done anything at all that could have possibly broken this.
Has this happened to anyone else? And what could possibly be the issue?
I think you might have to take a look at export function the plugin provides. Select a field group you created and hit export. It'll generate some code which is pretty good commented with tips and advice. There might be some information there for good use for 'ya.
Example by the plugin developer:
Include in theme
The Advanced Custom Fields plugin can be included within a theme. To do so, move the ACF plugin inside your theme and add the following code to your functions.php file:
include_once('advanced-custom-fields/acf.php');
To remove all visual interfaces from the ACF plugin, you can use a constant to enable lite mode. Add the following code to your functions.php file before the include_once code:
define( 'ACF_LITE', true );
Hope it helps.
/Paul
Since my rep isn't high enough to reply to #Kortschot's response, I'll comment here.
I got this error while testing a new theme. It appears the theme has ACF bundled into the theme, which triggers the "Cannot redeclare acf_filter_post_id()" error. For obvious reasons (you can't run two instances of the plugin in the same install). #Kortschot's reference to including ACF in a theme helped solve my problem.
Now I have to figure out how to access ACF if I want to customize fields on pages/posts...
I'm gonna go ahead and reply to this old question in hopes that it helps someone out. I have been having this problem where my fields would not update on my custom posts. I usually have multiple tabs open to make navigation easier in the backend of WP. It turns out that when I closed all other tabs except the current one I'm editing, the fields update every time!
I have same problem with Advanced custom fields plugin , i resolve my issue by adding one line code in advanced-custom-fields/core/controllers/post.php
add_action('pre_post_update', array($this, 'save_post'));
after
add_action('save_post',array($this, 'save_post'), 10, 1);
line number 33, 34.
I had the same problem and fixed it by creating unique field names.

WordPress custom post type category order

I'm looking for a way to manually reorder the category list for custom post types,
are there any plug-ins that already do this?
I can probably code my own, but I'm not sure where to start, can you add custom fields to the categories that can be used to order them?
Anything to point me in the right direction would be great!
EDIT [resolved]
After a bit more digging I uncovered this:
http://wordpress.org/support/topic/plugin-my-category-order-custom-taxonomy-order-and-code-improvements
Which linked to this:
http://snipplr.com/view/48599/mycategoryorder-custom-taxonomy-mod/
and once you change line 51 to you custom taxonomy type it works like a charm, eg:
$tax = ($_GET['mytax'])? $_GET['mytax'] : 'category';
becomes
$tax = ($_GET['mytax'])? $_GET['mytax'] : 'my_custom_taxonomy';
works perfectly with 'Types' plugin linked by #Ajay Patel, cheers.
Not able to get you question perfectly.
But use this plugin Types - Custom Fields and Custom Post Types Management
Types makes it easy to customize the WordPress admin. Define your own content using custom post types and custom taxonomy. Redesign editing screens using custom fields.

Wordpress: Multiple Custom Post Type

After long search with no luck, finally I have decided to ask here.
I am creating WordPress theme and need to add multiple custom post type for some additional featured which I will use rapidly or can say that will be my main use for the site.
Adding single custom post type there is not problem but I want to add more than two, three or more in future. I have tried to use same code by changing register post type name but its not working and giving some error.
I would appreciate if anyone can help me to create multiple post type with multiple taxonomy and post tag for each CPT.
I will really thankful and appreciate your effort.
Try this http://wordpress.org/extend/plugins/custom-post-type-ui/
try this plugin which is very easy to use
custom post type maker

Resources