Tag Info

New answers tagged

0

If you are not sure how your site will behave when upgrading or changing themes, you should create yourself a test/dev site. There are many tutorials out there that can help you set up a local test site. You can make a copy of your live site and transfer that all to your test site locally. From your question I suspect that you registered your taxonomies ...


0

I'm not sure how you're planning to deal with these terms, but I think you can still use WPML native way to handle terms translations, even though you can't keep the same slug. When you need to deal with a term slug, you can rely on the icl_object_id() function. For instance, suppose you have English as default language, and Italian as a second language. ...


0

Turns out you can't use uppercase taxonomy ids. Those work, mostly, but when WordPress sanitizes Ajax calls, everything uppercase is converted to lower case and it won't find the correct taxonomy. The solution is to only define and use lowercase taxonomy ids.


0

You must place (delete) some posts in trash bin first to make this options appear. The same with draft. You must first assign some post as "Draft" in edit screen. As I see in your screen, all your PDF CPT are published. So there's nothing in trash, and nothing is a draft.


2

There are no methods the_content() or the_title() of your query object. These: $review_query->the_content(); $review_query->the_title(); should just be the_content(); the_title(); If you had debugging enabled you would see an error informing you of this.


0

At first glance, I see that your query is calling for 'post_type' => 'page' while the taxonomy is registered on the post object type. Changing the post type to post ('post_type' => 'post') should fix the problem.


0

After researching s_ha_dum's link and others for a while it seemed like the only way to position meta boxes in between the title and editor fields was to remove and readd the main editor like this, but this feels a bit hacky to me and receives a warning from another answerer about potential problems. I was able to combine @s_ha_dum's method for creating a ...


0

You just need to override the function display_tablenav() with a blank function in you parent class. It is explained here.


2

In your case you can edit the following code to accomplish what you are looking for by assigning the custom taxonomy meta box to a custom context and then running do_meta_boxes /** * insert meta boxes before main editor below title */ function wpse_140900_add_meta_boxes_after_title( $post ){ // per the comment below filter by post type // ...


0

Found the answer: $categories = get_terms( 'category', array('hide_empty' => false) );


0

You can also append &posts_per_page=-1 to the query_string inside query_posts: if ( have_posts() ): query_posts($query_string.'&posts_per_page=-1'); while ( have_posts() ): the_post(); etc


0

Thanks to this great tutorial, I just found the answer myself. Wordpress offers the action hooks sb_reference_category_add_form_fields, sb_reference_category_edit_form_fields, create_sb_reference_category and edited_sb_reference_category (these are namef after the custom taxonomy, in my case sb_reference_category). With these hooks, it is easy as pie to add ...


2

See Taxonomy Parameters in Codex. First — areas should probably be in your tax_query as well. Second — you probably need to make use of operator argument in queries (inner ones). I am not sure without testing this out but AND seems like it would for more strict matches than default IN for your mandatory types/features logic.


2

What you want to do is impossible without a page.php type of template. There is no template hierarchy that support what you want to achieve. It works exactly the same with categories. taxonomy-categorycourses.php will not display a list of categorycourses, so would category-categorycourses.php if categorycourses was a normal category. If you click on ...


0

To guarantee that your taxonomy is never queried on the front end, you could strip it from all front end queries. add_action( 'pre_get_posts', function($qry) { if (is_admin()) return; $kill = 'genre'; // kill this taxonomy $tax_query = $qry->get('tax_query'); if (empty($tax_query)) return; $relation = false; if ...


0

UPDATE! OK!!! Woooohooo! Found out what it was.. I should have been calling if have posts before the call for $tax->name; Here is my final, and working code! :) <?php /**********************************************/ // CUSTOM WINE MENU SHORTCODE /**********************************************/ add_shortcode( 'wine_list_per_cat', 'wine_list_per_cat' ); ...


0

Use pre_get_posts to filter search results: function search_filter($query) { if ( !is_admin() && $query->is_main_query() ) { if ($query->is_search) { $query->set('post_type', 'custom_post_type_name'); $query->set('cat', intval($_POST['cat']); // assuming you have a select with categories with name "cat" } } } ...


1

By default when you run a query for a hierarchical taxonomy term, WordPress also returns post from its children. This happen on backend and on frontend as well. 'tax_query' argument has an argument 'include_children' that was introduced for the scope, from Codex: include_children (boolean) Whether or not to include children for hierarchical taxonomies. ...


0

If I understand correctly, the book and the reviews share same taxonomy. Then is just a matter of get the taxonomy term for the book in the single-books.php, save it in a variable and then run a query using that variable for the 'tax_query': if ( have_posts() ) { the_post(); // get the term for the current book and save in a variable $book_terms = ...


0

I figured it out. Setting 'relation' to 'OR' is important. <?php $myquery['tax_query'] = array( 'relation' => 'OR', array( 'taxonomy' => 'category', 'terms' => array('home-slides'), 'field' => 'slug', ), array( 'taxonomy' => 'miss_behave_category', 'terms' => array('home-slides-1'), 'field' => 'slug', ), ...


-1

try 'post_type' => 'any', 'category_name' => array('miss_behave_category','emily_category'),


1

Creating custom search is not the easiest of tasks for beginners. You will need templates search.php and searchform.php - View Codex. You can then edit searchform.php and add any fields you need. When the user submits the form it will also add any extra fields you have - so your search url may look something like this /?s=1000&num=5&type=years ...


0

Okay i found the problem was var_dump was executed before wordpress gets to any registered post type. so i added 199 in its priority and it worked. :) Thank you all for your help... function test(){ var_dump( get_post_types(array('_builtin' => false))); } add_action ('admin_init','test', 199);


0

Ok so I decided to go with regular categories and not custom taxonomies. For any one interested why a new post with custom taxomony defaults to un-categorized, is because it is linked to the post type which is "post". So you must also enable a custom post type "register_post_type()" that is linked to your custom taxonomies that will act as categories.


0

The literal implementation would be to: Create array variable While looping add to it ID of each post, using term name as key (so you have array of arrays) After main loop check the array and query additional posts if needed, using stored IDs for post__not_in so there are no duplicates Syntax will be something like this: $post_counts = array( 'learn' ...


1

Totally untested and I'm not 100% sure I understand your question, but this should (in theory) get 5 posts that share any of the same venues as the current post. I would probably suggest adding some Transients to this so that you aren't constantly running queries. If it doesn't work, I suspect the syntax of my tax query is a little off. It always gets me ...


0

You can use a tax query for all "Reference Type" terms, which will retrieve all attachments that have at least one "Reference Type" term. $rt_media = new WP_Query( array( 'posts_per_page' => -1, 'post_type' => 'attachment', 'tax_query' => array( array( 'taxonomy' => 'reference_type', ...


1

It seems you need a seft-closing shortcode. http://codex.wordpress.org/Shortcode_API will be a great read to get started.


4

You want to define a potentially huge number of different shortcodes with the same shortcode callback? Why don't you define a single shortcode, with a term attribute? For example [sc term="london"] ps: I think your problem lies in the $tax_term->name part, which could be a string like City of London and that's not a valid shortcode name. Try ...


0

The conditional is_* functions work on query, not on current post. In other words they tell you things about page you are on, however not about the current post. is_category() will check if current page is category archive has_category() will check if post has specific category assigned From your description I suspect you mean the latter.


0

While looking for a solution I got this post: Taxonomies with same slug as CPT So basically you need to add custom rewrite rules, I haven't tested the solution but I guess it will work out for you. /* Register CPT */ function wpse_138987_post_type_filter() { register_post_type('filter', array( 'labels' => array( 'name' => 'Filter', ...


4

However, this will turn ALL terms checkboxes to radio buttons. Not only that, it'll turn any checkbox in a meta box - not ideal! Instead, let's specifically target the wp_terms_checklist() function, which is used to generate the list of checkboxes across the admin (including quick edit). /** * Use radio inputs instead of checkboxes for term ...


0

You will need to join four table to get cateogries of custom post type "review" wp_term_relationships wp_posts wp_term_taxonomy wp_terms by using following query you can get list of categories applied to your custom post type: SELECT * FROM wp_term_relationships AS tr LEFT JOIN wp_posts AS p ON tr.object_id = p.ID LEFT JOIN wp_term_taxonomy AS tt ON ...


0

*Moved comment to answer as suggested by @kaiser * Original comment accepted as answer If you are using the default wp template hierarchy (which it looks like you are) you won't need any special WP query, WordPress will just know. So take a standard loop. Make a backup of that template, then add a normal WP look and see how you get on. It should ...


0

If you're actually using categories (and not a custom taxonomy) then your $categoryname variable needs to be the slug, not the actual name. Admittedly this Wp_Query argument name is confusing. If, however, you are using a custom taxononomy (and you'll know if you are) then you should use 'name-of-your-custom-tax' => 'slug' instead. The codex is your ...


-3

I believe you need to make sure your custom taxonomy does not have a capital letter in the name parameter. It took me quite a while to realize that on a site a few months ago. edit: My comment refers to the use of register taxonomy, which in second review it looks like you are using the proper naming convention for the taxonomy name parameter.


0

I believe that what you want is show_option_none show_option_none (string) Set the text to show when no categories are listed. Defaults to "No categories". http://codex.wordpress.org/Template_Tags/wp_list_categories#Parameters Proof of concept: $args = array('include'=>123,'show_option_none'=> ''); wp_list_categories( $args );


0

I did few tweaks on the earlier code, the first filter is working fine for now, I am little confused on the rest any suggestion sven ? can you help me to bring this effectively. function onchangedestination(str) { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); ...


0

Answer moved from an edit in the answer to a real answer. This is my query <?php $taxonomy = (get_post_type() == 'post' ? 'category' : (get_post_type() == 'news' || is_tax('news_categories') ? 'news_categories' : 'category')); $tax_terms = get_terms($taxonomy, array('hide_empty'=> false) ); ...


1

One simple option would be to add a parameter to the query string of the portfolio item (i.e. yousite.com/portfolio-item/?backto=portfolio-3), then on the item page modify the 'back' link with JavaScript: if the backto parameter exists then change the link to point to the portfolio specified in it. Here's some untested starter code. On the portfolio page ...


0

It does't work because you can't use set to change all query vars. Simplest way to do the trick is set 's' to an empty string: add_action( 'pre_get_posts', function( $query ) { if ( ! is_admin() && $query->is_main_query() && $query->is_search() ) { $taxquery = array( ... ); $query->set( 'tax_query', $taxquery ); ...


0

You can try to get that information by using the get_term_by() function with the relevant parameters of the menu item (namely object and object_id) : foreach( (array) $menu_items as $key => $menu_item ) { // Match the menu items to your custom taxonomy: if( 'solutions_category' === $menu_item->object ) { // Fetch the corresponding ...



Top 50 recent answers are included