Tag Info

New answers tagged

1

Solution: //make sure these custom post types are registered for taxonomy queries add_filter('pre_get_posts', 'query_post_type'); function query_post_type($query) { if(is_category() || is_tag()) { $post_type = get_query_var('post_type'); if($post_type) $post_type = $post_type; else $post_type = array('nav_menu_item', 'venue', ...


0

I don't have the reputation to comment so I will put this here. Extending Will's example. I changed the LIKEs to "=" and have them both point to WHERE post_type UPDATE `wp_posts` SET `guid` = REPLACE(`guid`,'old_post_type','new_post_type') WHERE `post_type` = 'old_post_type' UPDATE `wp_posts` SET `post_type` = ...


-1

I found that if I removed the get_transient and set_transient functions from lines 8 & 15 then the CPT's loaded just fine. Thanks for the help everyone!


1

Found the basis of the answer buried in the codex $args = array( 'post_type' => 'case_studies'); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); the_ID(); endwhile;


0

You could try this way. Create a new page called say 'All products' and apply the following template to it. Here is the code for that should be used in your template, just above the while loop. $type = 'products'; $args=array( 'post_type' => $type, 'post_status' => 'publish', 'posts_per_page' => -1, 'caller_get_posts'=> 1 ...


0

If you are using Advanced Custom Fields you can use the get_field() method. function fields_in_feed($content) { if(is_feed()) { $post_id = get_the_ID(); $image = get_field('img', $post_id); $output = '<acfTitle>' . $img['title'] . '</acfTitle>'; $output .= '<acfImage>' . $img['url'] . ...


2

This is a known bug (or design flaw) that seems be getting some attention by the Wordpress team. Take a look at this discussion https://core.trac.wordpress.org/ticket/18962 for more information. As of Wordpress 4.0 this is still an issue.


0

They don't do this. Custom post statuses are basically a trap. They seem like they might make sense, but likely they won't do what you think they will do and cause ton of grief with edge cases on top. You should consider custom taxonomies for your CPT–specific data. They are much more robust and safe to use for something like this.


0

I got the client to agree to a slightly different slug so that all the CPT's pages used a parent of "practitioners" and the pages I was trying to create could use "practitioner" without the S, it simplified things alot and users may not notice or even care!


0

That's normal because projects CPT posts are not child items of Projects page. Projects page is just to display project CPT posts. Now how to highlight Projects page when viewing single project. That's where body classes comes handy. You can use body classes to highlight and unhighlight a menu item based on the page, cpt or section you are viewing. For ...


1

There are couple of issues in your query. There is not parameter named category. You can use these following. cat (int) - use category id. category_name (string) - use category slug (NOT name). category__and (array) - use category id. category__in (array) - use category id. category__not_in (array) - use category id. If you need your query to paginate ...


2

Yes, you need to write code to populate it. This is untested but should work. add_filter('manage_edit-cpt_roundtable_columns', 'init_roundtable_custom_columns'); function init_roundtable_custom_columns($columns) { return array( 'cb' => '<input type="checkbox" />', 'title' => __('Title'), 'taxonomy-sessions' => ...


-1

try changing the value of 'posts_per_page' => '-1' this is what's probably messing up your query, if you want two try setting it to : 'posts_per_page' => '2' also try to comment it out..... I think it's quite self-explanatory, but to really understand wp-query read the Codex ref..


1

You specify supported taxonomies right there: 'taxonomies' => array( 'category', 'post_tag' ), If you want different set you should configure it accordingly. Possibly registering custom taxonomies if that is what needed.


1

There seemed to be an issue with the way you registered the taxonomy. I prefer to register the taxonomy first, before registering the post type. I submitted a pull request but here ya go: <?php // hook into the init action and call create_book_taxonomies when it fires add_action( 'init', 'create_ksasexhibits_taxonomies', 0 ); // create two ...


1

From your comments, this only happens when the fields are left empty. This means that the particular field does not get set. As stated in my comments, you should first check if a field is set before you try to use it. In the first block of code, you have the following three lines <td><input type="text" class="widefat" name="name[]" ...


1

I think you could do this with one template such as single-property.php. As Sanchy recommended you would want categories for "sale" and "rental." You would also want custom fields for the data. The Advanced Custom Fields Plug-in makes it easy to add those. https://wordpress.org/plugins/advanced-custom-fields/ Add all the ones you would want for both rental ...


0

This might serve as a work-around. Try changing the name of your post-type from "Portfolio" to something like "Work" or "Examples." It just needs to be a word that makes sense to you. Then change the name of your taxonomy from "Type" to "Portfolio." I think WordPress defaults to showing the relationship of the term to the taxonomy because there could be ...


3

Step 1 Start by making an Advanced Search Form with which you want your user will interact with the website, and save it with a name (i.e. I saved it as advanced-searchform.php — but don't save it with searchform.php then it'll replace the WordPress' default search form): <form method="get" id="advanced-searchform" role="search" action="<?php ...


0

Yes, it is possible, and it is done by creating the custom taxonomy, then creating the rewrite in the custom post type, and then adding a filter for post_type_link to edit the actual permalink. Once you have the code in place, you have to go Settings > Permalinks and hit submit to refresh everything. add_action( 'init', 'register_custax_type', 0 ); function ...


0

Doesn't exist any is_post_type_single function, because there is no need for it. is_singular() fit perfectly your purpose. Example code using 'template_include' filter: add_filter( 'template_include', function( $template ) { if ( is_singular( array( 'cpt-1', 'cpt-2', 'cpt-3' ) ) ) { $locate = locate_template( 'custom-template.php', false, false ); ...


0

Each CPT should have its own templates. If there is common code then you should write it as a function in the functions.php of the theme and call it, or use a different file and include it from all of the single php template, whatever fits your coding style better. That said, if you think that all your CPTs should be displayed at the same way then you ...


0

WordPress will autoload different templates for custom post types: Template file used to render a single post page. single-{post_type}.php - If the post type were product, WordPress would look for single-product.php. http://codex.wordpress.org/Template_Hierarchy#Single_Post_display That should be all you need to load your "slightly ...


1

Add categories to your custom posts. Ex: add_action( 'init', 'create_gallery_taxonomies', 0 ); function create_gallery_taxonomies() { $labels = array( 'name' => _x( 'B&A Categories', 'taxonomy general name' ), 'singular_name' => _x( 'B&A', 'taxonomy singular name' ), 'search_items' => __( 'Search B&A ...


0

Most of the "Staff" or "Employee" plugins listed in the WordPress Plugin Directory also include a private field or a field that can be used as private that may serve the purpose of entering inventory into a text box. But that wouldn't allow for quickly querying the DB for employees that have laptops. Adding a simple staffing plugin, and manually adding a ...


0

Use the following function: wp_list_categories();. You can find more information on the codex. Here is how to display the list: <?php $args = array( 'taxonomy' => 'portfolio_taxonomy', // your custom post type Taxonomy 'order' => 'ASC' // Order of the list ); wp_list_categories($args); ?>


0

You can use this code with native WordPress Uploader. If you assing your images to custom field you must use get_post_meta like functions. The basic way, Upload your images from Add Media area to your post and use this code in your single.php or which theme file you use. if ($migallery = get_children( array( 'post_parent' => get_the_ID(), ...


0

I find the solution, that's a WordPress 4 year's bug. Here is the Summary from DrewAPicture changed from manually created user roles not showing in author dropdown irregardless of assigned capabilities to Manually created user roles not showing in author dropdown regardless of assigned capabilities Please see ticket 16841 for more details. The only ...


4

You have totally missed the naming convention when coming to the taxonomy archive pages, and most probably the same goes for your archive pages for your custom post types Here is how your taxonomy archive pages should look like taxonomy-{taxonomy}-{term}.php - If the taxonomy were sometax, and taxonomy's term were someterm WordPress would look for ...


1

It is because of 'has_archive' => true which instruct wordpress to look for an archive template for the CPT. If you have a page with the same slug (portfolio) it will never get to display it as everything gets priority over pages.


0

Since I found this article as the first result in Google, I just wanted to comment that WP now offers a function to handle this sort of task. Within the add_meta_box function, add the following code --> wp_editor( $content, $editor_id, $settings = array() ); Wherever you want to add the TinyMCE editor Reference: wp_editor


1

I ended up having to use the Post 2 Post plugin to get this to work. Apparently WP isn't great with creating relationships at the moment, so plugin help is needed. After much searching, this is the solution I came across and I've no affiliation with the creator of the plugin...just happy that it solved my problem. A description from the WP Plugin page: ...


1

Before I start, you should not use capital letters in your names, and also, don't use hyphens, the correct way is to separate words with underscores What you are trying to do doesn't work. Do a var_dump() to get the available query variables on your single page ?><pre><?php var_dump($wp_query->query_vars); ?></pre><?php You ...


0

Assuming that: slug of your taxonomy is movie slug of your term is b you are using pretty permalinks your website is accessible at: www.example.com You can see a list of all posts which have been assigned this specific term under this taxonomy by going to: www.example.com/movie/b/ This page will display posts from all custom post types to which this ...


2

You have a couple of problems with your code customtaxonomy=$mytaxonomy is incorrect. First of all, there is no parameter called customtaxonomy in get_posts. Secondly, your syntaxing is wrong. If you make use of a varaible, your syntaxing should look like this 'post_type=myposttype&customtaxonomy=' . $mytaxonomy . '&posts_per_page=-1' You should ...


1

In your function, you have this line: $mytaxonomy = get_posts('post_type=myposttype&$customtaxonomy=$mytaxonomy&posts_per_page=-1'); Try changing it to: $mytaxonomy = get_posts('post_type=myposttype&customtaxonomy=$mytaxonomy&posts_per_page=-1'); $customtaxonomy is a variable. customtaxonomy is a parameter.


0

WordPress oEmbed uses Twitter cards which should be at least as and possibly more SEO friendly than Storify.


0

Custom Post Type Templates archive-{post_type}.php single-{post_type}.php archive-{post_type}.php If your custom post type were 'product', and/or query_var = "product", WordPress would look for archive-product.php to display the archive of posts. single-{post_type}.php If your custom post type were 'product', and/or query_var = "product", WordPress ...


1

You should have a look at the register_post_type page in the codex. Look at the hierarchical argument when registering your post type hierarchical (boolean) (optional) Whether the post type is hierarchical (e.g. page). Allows Parent to be specified. The 'supports' parameter should contain 'page-attributes' to show the parent select box on the ...


0

No, by default you can not add support for templates to custom post types. But there are some plugins that allow this functionality. You can use Custom Post Template or Single Post Template Plugin plugin to add template support for single posts which includes custom post types too. You can read more about it here. Can I assign a template to a custom post ...


0

(1) The Edit Permalink HTML including the View-Post button is passed through the get_sample_permalink_html filter. You will likely have to preg_replace() the view post button out of it: function my_get_sample_permalink_html($a){ return preg_replace("/<span id='view-post-btn'>(.*)<\/span>/",'',$a); } ...


0

Use Storify to collect groups of related tweets and other content, then embed the groups on your blog.


1

You have a couple of conflicting arguments here, but what you want to do is completely possible. To keep something out of the RSS feeds, and considering it really is a different type of content from your blog posts, I'd recommend a custom post type called "Links" or something. The custom post type will have its own archive and RSS feed, separate from your ...


1

Since WP 3.7 there is a filter "posts_search_orderby" that allow to set the ordering for search. To be sure that filter works as expected set "orderby" to "relevance". add_action( 'pre_get_posts', function( $query ) { if ( $query->is_search() ) { $query->set( 'orderby', 'relevance' ); } } ); and then, assuming your profiles CPT slug is ...


0

I was told about the fabulous posts 2 posts plugin which does exactly what I need. Issue resolved.


0

WordPress allows you to filter the results of a search. By default, it search on posts and pages, but you can add your customs posts types: function searchfilter($query) { if ($query->is_search && !is_admin() ) { $query->set('post_type',array('course','post','page')); } return $query; } ...


0

Custom post types are excluded from the main query by default (except on taxonomy pages and custom post type archive pages), that is why you don't see posts from your custom post type on your category page. You need to include your custom post type posts in the main query manually. That is done with pre_get_posts which alters the main query before it is ...


1

You are sorting it incorrectly. You will need to check for artist-status meta key with meta_query and sort by last-name metakey. Here is your query. $args = array( 'post_type' => 'artist', 'posts_per_page' => -1, 'meta_key' => 'last-name', 'orderby' => 'meta_value', 'order' => 'ASC', 'meta_query' => array ( ...


0

From Codex this snippet could be useful for you case: Display posts of type 'my_custom_post_type', ordered by 'age', and filtered to show only ages 3 and 4 (using meta_query) $args = array( 'post_type' => 'my_custom_post_type', 'meta_key' => 'age', 'orderby' => 'meta_value_num', 'order' => 'ASC', 'meta_query' ...


1

Use this: add_action( 'init', 'gp_register_taxonomy_for_object_type' ); function gp_register_taxonomy_for_object_type() { register_taxonomy_for_object_type( 'post_tag', 'portfolio' ); };



Top 50 recent answers are included