Tag Info

Hot answers tagged

5

There is a filter called get_user_option_meta-box-order_{$page} where $page is the name of the post type. Just make sure that submitdiv is the last value in the array: add_filter( 'get_user_option_meta-box-order_post', 'wpse25793_one_column_for_all' ); function wpse25793_one_column_for_all( $order ) { return array( 'normal' => join( ",", ...


4

This can be done using an Ajax call that will query the database and set the parent as "zero". First, create a meta box, enqueue the Javascript that calls the unattach function and register this WP_Ajax function. <?php /* Plugin Name: Unattach Meta Box Version: 0.3 Author: brasofilo Plugin URI: http://wordpress.stackexchange.com/q/54822 */ add_action( ...


4

The function register_post_type() takes an argument 'labels'. This is an array, one of the possible keys is named … tada! … 'menu_name'. Sample code register_post_type( 'academias' , array ( 'can_export' => TRUE , 'exclude_from_search' => FALSE , 'has_archive' => TRUE , 'hierarchical' => ...


3

Alternatively to Kaiser's answer, when you register the post type, simply use the taxonomies attribute: register_post_type( 'my-cpt', array( ... 'taxonomies' => array( 'category' ), ... ) ); Details on register_post_type() can be found here in Codex.


3

One approach is to remove the original metabox, and then to re-add that metabox, with updated parameters. For example, this will move the "Featured Image" meta box from the side column to the main column, for a custom post type with a slug cpt-slug: Edit The parameter for the Publish meta box is submitdiv, and the correct callback is ...


3

Here this is my code which i used in my wordpress site in custom post type for adding the pdf to the post and its work for me try to change its and use it. Hope it will help function add_custom_meta_boxes() { add_meta_box('wp_custom_attachment', 'Hotel Brochure', 'wp_custom_attachment', 'hotel_post', 'normal', 'high'); } add_action('add_meta_boxes', ...


2

You can use WordPress built in gallery, see Gallery Shortcode. If you look for the gallery shortcode function in WordPress core, you can see how it grabs the image attachments to a post with get_children and outputs them. You can use this as a starting point to write your own function to output the gallery with your own markup and css / js by filtering ...


2

There are way's to get around it to create this kind of grouping or relationship: "manually" - set the post_parent field to the parent ID (by manually i mean code something that will do that for you when you publish a CPT). Using a shared custom taxonomy to create a grouping of posts and you will have the ability to filter / query posts based on that ...


2

To avoid this from happening simply add flush_rewrite_rules( false ); after your register_post_type function. you can read about it more here http://en.bainternet.info/2011/custom-post-type-getting-404-on-permalinks


2

When you're viewing a Custom Post Type Archive, your archive-documents.php template will be used. In your case this is the URL /documents/. When you're viewing a taxonomy term, you're viewing a Custom Taxonomy Archive, not a Custom Post Type Archive. If you haven't created one specific to your taxonomy, then archive.php (or index.php, if archive.php doesn't ...


1

Additional info for @StephenHarris answer: When you register a taxonomy and a post type and want to connect them, there's one important rule: Always register the taxonomy first. Then register the post type. The reason is simple: Take a look at the source of register_taxonomy(): // Adds the 2nd argument ($object_type) to the arguments: ...


1

You can use wp_list_categories() which by default, generates nested unordered lists (ul) and just pass product-category as the taxonomy parameter for example: add_filter('wp_nav_menu_items','add_custom categories', 10, 2); function add_custom categories($items, $args) { $items .= '<li>' . wp_list_categories( array('echo' => 0, 'taxonomy' ...


1

You can either set the taxonomies parameter of register_post_type, which accepts an array of taxonomies, or set object type to your custom post type (or array of types) when you register your taxonomy, or you can use the register_taxonomy_for_object_type function.


1

Looks like this question is a several months old, but it's a good one so I'm digging it out of the grave. The way I would go about solving it would be to intercept any searches with the pre_get_posts filter and add in the meta query based on the provided information. Here's a basic shot at the solution, which can become a plugin or go in your theme's ...


1

Try moving your foreach into the script tag, as such : In the images parameter of your javascript : //[...] images:[ <?php foreach( $slider_posts as $post ) { $thumb = wp_get_attachment_image_src(get_post_thumbnail_id(), 'home-slide'); echo '"' . $thumb[0] . '",'; //Assuming images are separated by a comma } ...


1

The quick and dirty way is set the published date a year or so in the past, past the oldest posts in the feed. There's also a nice plugin for this - Stealth Publish - where you set a flag in a custom field to exclude it from feeds and the home page feed.


1

something along these lines should do it: $args = array( 'post_type' => 'listings', 'posts_per_page'=> -1, 'post_status' => 'any', 'tax_query' => array( array( 'taxonomy' => 'status', 'field' => YOUR FIELD NAME HERE??? 'terms' => 'standard' ) ) ); $query ...


1

I don't know what content you want to insert in your archive page, but you can always use the file "archive-friends.php" as you can see in the Template Hierarchy to loop your "friends" post type. Then, to customize the SEO, I recommend you the plugin WordPress SEO by Yoast because it has a strong compatibility with custom post types, so that you will be ...


1

The posts and post_meta tables are made for regular blog posts and similar content. Look at the schema and ask yourself: Do I need these fields? CREATE TABLE $wpdb->posts ( ID bigint(20) unsigned NOT NULL auto_increment, post_author bigint(20) unsigned NOT NULL default '0', post_date datetime NOT NULL default '0000-00-00 00:00:00', post_date_gmt ...


1

That function looks like the kind of thing that would slow down a site. :) The first thing I'd recommend is that you not run that function on the front end. Run it when the image is uploaded and store the result in the database using wp_update_attachment_metadata. You can then retrieve the data with wp_get_attachment_metadata. An administrator/editor can ...


1

I think your test is flawed. It is the original query-- the one you save to $temp-- that is important for working out which template loads. You overwrite that and paginate based on that overwritten query. That means that the pagination is out of sync with the original query. When you click a pagination link and then the page loads a query runs that does ...


1

I don't know the URL of an extension-less image to test this but I'd think that the server would have to pass a content-type header. If that is the case, you should be able to look at $get['headers']['content-type'], find out what kind of image it is, and tack the appropriate extension onto $image_file_name before sending it to wp_upload_bits. You've ...


1

or printed "Array" That is your clue. Array indicates something is being returned, you just need to make use of it. Try var_dump($processing) and see what the array contains. In my plugins I have a functioned called example_var_dump(); and it is setup to use before the var_dump() line and after it. This displays arrays in a readable fashion. Plus I ...


1

In database, it stores the date details with prefix as _start and _end so you need to change the meta keys accordingly. Please have a look at the below code. <p>Start time details</p> <p>Date: <?php echo get_post_meta($post->ID, '_start_day', true);?>.<?php echo get_post_meta($post->ID, '_start_month', true);?>.<?php ...


1

Use the function register_taxonomy_for_object_type to add existing taxonomies to existing post types: function wpa_tags_for_cpt(){ register_taxonomy_for_object_type( 'post_tag', 'post_type_name' ); } add_action( 'init', 'wpa_tags_for_cpt', 999 );


1

As the other gentlemen have mentioned in the comments, due to the libraries that source uses, strings are returned. If you need to convert to an integer for a comparison or function call, just use WordPress's absint function . $int_id = absint( $wp_posts[0]->ID ); Also, not sure if your DB call is just simply an example, but I suggest using get_posts, ...


1

When your taxonomy is already registered (or is a built-in one like post tags, categories, etc.), you can simply glue it to a post type by using register_taxonomy_for_object_type(): register_taxonomy_for_object_type( 'category', 'course' ); Just make sure you do that after both the taxonomy and the post type are already registered.



Only top voted, non community-wiki answers of a minimum length are eligible