Get URL for specific post type and current tag

If the URL to the ‘cancer’ taxonomy term in your example looked like this: yourwebsite.com/topics/cancer/ then you could filter these results by post type with a URLs structured like this: yourwebsite.com/topics/cancer/?post_type=question Just put this in functions.php add_filter( ‘pre_get_posts’, ‘wp123_post_type_by_taxonomy’ ); function wp123_post_type_by_taxonomy( $query ) { if( is_tax( ‘topics’ ) && $query->is_main_query() ) { // get … Read more

Custom Taxonomy and tax_query Issue?

I think that the problem is right in your code, but it’s really easy to overlook. Let’s take a closer look at this part: <div class=”col-md-4″> <?php echo $category_name = $get_categories[$i]->name; ?> </div> <?php $args = array( ‘post_type’ => ‘team’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘Team_Category’, ‘field’ => ‘slug’, ‘terms’ => $category_name ) ) … Read more

Replacing the title in admin list table

1. Change post title in post list column I misunderstood what you wanted – obviously. You can do that like this: add_action( ‘admin_head-edit.php’, ‘wpse152971_edit_post_change_title_in_list’ ); function wpse152971_edit_post_change_title_in_list() { add_filter( ‘the_title’, ‘wpse152971_construct_new_title’, 100, 2 ); } function wpse152971_construct_new_title( $title, $id ) { //print_r( $title ); //print_r( $id ); return ‘new’; } Making use of the admin_head-$hook_suffix … Read more

Remove “-2” from a Toolset Types URL with the same post name

It can be done by using the request filter. Something like this function alter_the_query($request) { return array(‘page’ => 1, ‘pagename’ => null); } add_filter(‘request’,’alter_the_query’); Here it forces display of post 1, though of course you will want to do a query to determine the ID. For that, it might prove easiest to first parse the … Read more

Adding a span when custom post type is updated

No, you’re right. This is the code that is responsible for ‘New’ span: <?php if (strtotime($post->post_date) > strtotime(‘-14 days’)): ?> <div class=”new-job-tag”><span>New</span></div> <?php endif; ?> The only problem with your modification is that there is no field called the_modified_date in WP_Post object. The proper name of that field is post_modified, so your code should look … Read more

Enabled Revisions to existing custom post type not working WordPress

$cap_type=”post”; $plural=”Products”; $single=”Product”; $cpt_name=”products”; $opts[‘supports’] = array( ‘products’, ‘title’, ‘editor’, ‘thumbnail’, ‘author’, ‘revisions’ ); $opts[‘can_export’] = TRUE; $opts[‘capability_type’] = $cap_type; $opts[‘description’] = ”; $opts[‘exclude_from_search’] = FALSE; $opts[‘has_archive’] = TRUE; $opts[‘hierarchical’] = TRUE; $opts[‘map_meta_cap’] = TRUE; $opts[‘menu_icon’] = ‘dashicons-products’; $opts[‘menu_position’] = 2; $opts[‘public’] = TRUE; $opts[‘publicly_queryable’] = TRUE; $opts[‘query_var’] = TRUE; $opts[‘register_meta_box_cb’] = ”; $opts[‘rewrite’] = … Read more

Custom Post Types – How to include custom fields

@vemuez you need to enqueue js and css files to admin_print_script and admin_print_style here is the example to how to do it // Register datepicker ui for properties function admin_homes_for_sale_javascript() { global $post; if($post->post_type == ‘homes-for-sale’ && is_admin()) { wp_enqueue_script(‘jquery-ui-datepicker’, WP_CONTENT_URL . ‘/themes/yourthemename/js/jquery-ui-datepicker.min.js’); } } add_action(‘admin_print_scripts’, ‘admin_homes_for_sale_javascript’); // Register ui styles for properties function admin_homes_for_sale_styles(){ … Read more