Hot answers tagged

6

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', ...


5

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( ...


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

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

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

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.


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

Yes, this is pretty easy using something like Gravity Forms


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

1) add "comments" to the supports array when registering the post type. 2) add the comments_template() function inside the loop of the single.php template and you are good to go.


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

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 ...


2

Store the post id of the business in a post meta field of the product (_business_id), or create a custom table, because post meta look-ups are rather slow.


2

This is normal WordPress behaviour. Any time it detects that a slug is a duplicate - regardless of post-type or parents or categories - it will append a number to differentiate the newer version. As far as I know, there is no way to override this.


2

There are many choices here, and it is all up to you what you want to achieve and how you want to achieve it. My idea would be to use the templates available to avoid a lot of if else conditional statement. The Template Hiearchy makes provision for templates for terms, taxonomy-{$taxonomy}-{$term}.php, so you could create a tempate for each term. So for ...


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

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

There is no member argument for WP_Query, you want to pass the user ID as author.


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

You can post code directly into your question. You should edit the question to add your code so we don't have to go looking for it. Plus if you ever delete that pastebin, this question is worthless to future users. You have registered the post type to have an archive, and then your template is repeating the query for tutorials. That isn't very efficient. I ...


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

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

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

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

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

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

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

Use get_query_var('page') instead of get_query_var('paged'). Related ticket: #21028


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

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 ...



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