New answers tagged

0 votes

How to disable the single view / search /archive page for a already-built custom post type?

this custom post type is created by a plugin, I can't update the register_post_type code You can use either the register_post_type_args or register_<post type>_post_type_args hook to filter the ...
Sally CJ's user avatar
  • 38.7k
0 votes

Custom Post Type - archive working - single is not

After some time banging my head against the wall, I found the solution. I used https://underscores.me/ as a starter for my theme. One function sets the main query, where one can add custom post types ...
Keanu1989's user avatar
0 votes

Сustom posts are displayed in the wrong menus

@rudtek Thank you very much for your detailed answer and your advice, I will use them. I'll be sure to add a point to your answer when I can. It’s a bit awkward for me to say this, but the mistake was ...
upkagefa's user avatar
0 votes

Сustom posts are displayed in the wrong menus

There is an assorted list of issues on your code. When I load your code I'm not seeing the same thing you do. I'm seeing it create a second posts section and a second pages section, which is what it ...
rudtek's user avatar
  • 6,061
0 votes

Remove slug from custom post type post URLs

"Remove CPT base" plugin works. https://wordpress.org/plugins/remove-cpt-base/
Sridhar Katakam's user avatar
0 votes

How to delete all posts from a custom post type?

Few method or approaches you can take to delete all posts from a custom post type. 1 Use WP-CLI (WordPress Command Line Interface) If you have access to WP-CLI, you can use the following command to ...
vijay pancholi's user avatar
1 vote
Accepted

Post current post type to my Ajax

To pass the current post type to your AJAX request, you need to modify your JS to include the post type information in the AJAX request. You can achieve this by adding the post type as a parameter ...
vijay pancholi's user avatar
0 votes

How does WordPress manage to differentiate between post and page URLs without a distinct base, and how can I replicate this functionality?

I dont know how I missed out on that while looking for aproaches, but I have a working solution now based on this answer. I modified it to check for slashes in $query->request, if there is none I ...
Rick Pestel's user avatar
1 vote

Post current post type to my Ajax

Hi please replace your ajax function like this function filterPosts() { $show_post_types = get_post_types(); $post_type_array = array(); foreach ($show_post_types as $pt) { ...
Pratik bhatt's user avatar
  • 1,230
0 votes

WP_Query to select custom post type with Advanced Custom Fields (ACF) date

Your code looks mostly correctly but you are using a meta_query to filter posts based on the "End Date" field, and you are combining conditions with an OR relation, which is appropriate for ...
vijay pancholi's user avatar
0 votes

Add %post_id% to slug of custom post type and prevent the "unique slug" thing that WP does?

Get the result for permalink structure for your custom post type "equipment" and prevent WordPress from appending a number to the slug if there are posts with the same title, you can use the ...
vijay pancholi's user avatar
0 votes

Get Posts in a Custom Post Type category

I know this is old, but I wasn't able to find a clear answer. So here is what worked for me: WP_Query version: $args = array( "post_type" => "story", "story-...
user2250071's user avatar
0 votes

Selecting posts older than the current Unix epoch timestamp

you are trying to compare the combined date and time custom fields with the current time to filter out posts that are older than the current time. Replace combined_date_time with the actual meta key ...
vijay pancholi's user avatar
0 votes

Remove Custom Taxonomy Metabox from Custom Post Type Screen

Try this one or add 'meta_box_cb' => false to your $args in register_taxonomy add_action('init', function () { register_taxonomy('your_taxonomy', 'your_post_type', [ 'labels' => [ ...
Jxk427 Egamberdiyev's user avatar
1 vote
Accepted

Show category only if post type is post_three

you can modify your get_categories function call to include the tax_query parameter to specify the taxonomy and terms you want to retrieve. I have added the taxonomy parameter to specify that we are ...
vijay pancholi's user avatar
1 vote

Show category only if post type is post_three

Try this <?php // Get the current post ID $current_post_id = get_the_ID(); // Get the post type of the current post $current_post_type = get_post_type($current_post_id); ...
Zeshan's user avatar
  • 146
1 vote

Hide content box with Custom Post Type?

You can also set editor false $supports = array( 'title', // post title 'editor'=> false, // post content 'author', // post author 'thumbnail', // featured images 'excerpt', // ...
Shubham Verma's user avatar
0 votes

Limit taxonomy terms added to a custom post type

To limit the number of taxonomy terms that can be added to a custom post type in WordPress, you can use a combination of JS and WP function limit_taxonomy_terms($taxonomy, $post_type, $limit = 1) {...
vijay pancholi's user avatar
0 votes

Create action running on trashed_post hook to modify post_meta value

before_delete_post or wp_trash_post. Both hooks are triggered before a post is deleted or trashed. You can use one of these hooks to perform the necessary operations when a post of cpt_product_order ...
vijay pancholi's user avatar
1 vote
Accepted

Custom post type category pages pagination returns 404

The issue I'm having is with the pagination on category pages, e.g. /release-notes/category/upgrades/, where pages 2 and beyond return a 404. That's because your custom rewrite rule does not support ...
Sally CJ's user avatar
  • 38.7k
1 vote

How to sort custom post's category by id from the theme's function.php?

In your wp_dropdown_categories function call, you are using 'orderby' => 'NAME'. This argument is case-sensitive, and it should be 'orderby' => 'name' (all lowercase). $args = array( 'class' ...
vijay pancholi's user avatar
1 vote

Custom Field in Page Title

Use the wp_title filter, which passes the current title, separator, and location as arguments. It then appends the custom field value to the title if the conditions are meet. For more details :- Visit ...
vijay pancholi's user avatar
0 votes
Accepted

Search for portfolio tags & mixing portfoliotags and post tags

I put my answer to help others who can face the same issue. Thank you to all of the people who help me out to find the solution and valuable comments from this post. Please see my answer
made leod's user avatar
0 votes

WP_Query by a category id and a custom post_type

Get posts by category id $categories = get_categories(); $loop = new WP_Query([ 'posts_per_page' => 6, 'post_type' => 'post', 'tax_query' => [ [ 'taxonomy' =&...
Jxk427 Egamberdiyev's user avatar
1 vote

Make custom post type column sortable

To make your custom post type column auction sortable, you also need to handle the sorting logic in the query. You need to use the pre_get_posts action hook to modify the main query. The ...
vijay pancholi's user avatar
2 votes
Accepted

How to check if the post exists in any of the categories?

Since you are doing this for a custom taxonomy (solution_cats), then you should instead use has_term() and not in_category() which works only with the default/core category taxonomy. So try this with ...
Sally CJ's user avatar
  • 38.7k
0 votes

Rewrite taxonomy permalink appended to CPT archive url

To achieve the desired Term URL structure (https://www.domain.com/interventions/taxonomy-slug/) for your custom taxonomy in WordPress, you'll need to adjust your rewrite rules and ensure that your ...
WordPress Buddha's user avatar
1 vote

Add a post when another post type is inserting

The issue with your code appears to be related to the hook wp_after_insert_post being nested within the publish_service action. This setup can lead to the wp_after_insert_post action being added ...
WordPress Buddha's user avatar
0 votes
Accepted

Rewrite taxonomy permalink appended to CPT archive url

There are 2 possible ways to fix the issue with the term's permalinks (which is currently using the wrong query var name – intvn-cat): Easy. Just set the 3rd parameter for add_rewrite_tag() to ...
Sally CJ's user avatar
  • 38.7k
0 votes

My site has only one page, and users access my uploaded mp3 files from there - can I analyze access by song title?

You can collect class "track-content title" when someone play any of the music using google tag manager. you can link analytics plugin for precise details. https://www.lovesdata.com/blog/...
dig99's user avatar
  • 11
1 vote
Accepted

How to work with URLs where sometimes a post or a subcategory is in the same part of the URL structure

The other answer (from 'WordPress Buddha') almost worked, in fact I suspect on a plain WP install it would work fine, but on my site it appeared that some other plugins were running too early to ...
JoLoCo's user avatar
  • 111
0 votes

Search for portfolio tags & mixing portfoliotags and post tags

It sounds like you're encountering several issues with customizing search and tag functionalities in WordPress, particularly concerning portfolio and blog posts. Let's tackle each point step by step. ...
WordPress Buddha's user avatar
0 votes

Can the Next/Prev Post links be ordered by menu order or by a meta key?

None of the answers listed here or on the internet in general that I could find as of this writing seemed to offer a reasonably simple/elegant solution for presenting the Next/Prev Post links ordered ...
Collie's user avatar
  • 101
0 votes

Subpage for Custom Post Type

To create subpages like /location/berlin/visit, /location/berlin/hotels, and /location/berlin/about for each of your custom post types, you need to use WordPress rewrite rules and possibly custom ...
WordPress Buddha's user avatar
0 votes
Accepted

Subpage for Custom Post Type

Add the parameter hierarchical to the array with value true. This will allow you to create child posts on your CPT. Source: https://developer.wordpress.org/reference/functions/register_post_type/#...
Caleb's user avatar
  • 1,755
1 vote

How to work with URLs where sometimes a post or a subcategory is in the same part of the URL structure

Your challenge lies in the way WordPress interprets URL patterns and resolves them to query variables. When you have a URL structure where the third segment can be either a subcategory or a product ...
WordPress Buddha's user avatar
0 votes

How to set up a private custom post type that is accessible in the administrative dashboard?

Here ya go function YOUR_POST_TYPE_force_type_private($post) { if ($post['post_type'] == 'YOUR_POST_TYPE') $post['post_status'] = 'private'; return $post; } add_filter('wp_insert_post_data'...
Debbie Kurth's user avatar
0 votes

Admin Area Custom Type Search By Meta Fields Without Title & Content

function custom_post_type_search($query) { global $pagenow, $post_type; // Check if we are on the admin screen and it's the main query for the custom post type if (is_admin() && $...
vijay pancholi's user avatar

Top 50 recent answers are included