Topic Development – Add the_post additional elements in a custom post_type

I managed to create a custom post type (I called it stores) that worked in the loop. I plan to create a template with Bootstrap so that all stores have the same design and all can be changed with the editor. ,

What I need is a way to add additional items to the item (items like the_title, the_content, or the_time, but customized, like "the_type" or "the_storetype", etc.)

Add custom post-type taxonomies to the Categories widget

I wanted to see if this was possible, but I want to add the custom taxonomy categories of the custom post type to the WordPress Categories widget.

I know there is a filter as shown below:

add_filter('widget_categories_args', function() {
    $params('post_type') = array('post', 'recipe');
    return $params;
});
  1. My taxonomy is called recipe-categories Within wp_term_taxonomy and I want to be able to get all categories within the category widget.

  2. recipe is my custom post type.

  3. URL string is taxonomy=recipe-categories&post_type=recipe

Here are all the categories I have:

Enter the image description here

All I get back is that post Categories and not mine recipe Categories as shown below:

Enter the image description here

Gmail – Hii Sir, How do I save the JSON response? Flutter from the post-type API in the SQL Lite database

   This is my Model class

    import 'dart:convert';
    LoginModal welcomeFromJson(String str) => LoginModal.fromJson(json.decode(str));

    String welcomeToJson(LoginModal data) => json.encode(data.toJson());
    class LoginModal {
        bool status;
        String message;
        List data;

        LoginModal({
            this.status,
            this.message,
            this.data,
        });

        factory LoginModal.fromJson(Map json) => LoginModal(
            status: json("Status"),
            message: json("Message"),
            data: List.from(json("Data").map((x) => Datum.fromJson(x))),
        );

        Map toJson() => {
            "Status": status,
            "Message": message,
            "Data": List.from(data.map((x) => x.toJson())),
        };

    }

    class Datum {
        DriverDetail driverDetail;
        DriverSetting driverSetting;
        List supportDetail;
        DriverPermission driverPermission;

        Datum({
            this.driverDetail,
            this.driverSetting,
            this.supportDetail,
            this.driverPermission,
        });

        factory Datum.fromJson(Map json) => Datum(
            driverDetail: DriverDetail.fromJson(json("DriverDetail")),
            driverSetting: DriverSetting.fromJson(json("DriverSetting")),
            supportDetail: List.from(json("SupportDetail").map((x) => SupportDetail.fromJson(x))),
            driverPermission: DriverPermission.fromJson(json("DriverPermission")),
        );

        Map toJson() => {
            "DriverDetail": driverDetail.toJson(),
            "DriverSetting": driverSetting.toJson(),
            "SupportDetail": List.from(supportDetail.map((x) => x.toJson())),
            "DriverPermission": driverPermission.toJson(),
        };
    }

    class DriverDetail {
        int companyId;
        String driverName;
        dynamic loadId;
        dynamic cancelReason;
        dynamic availableTask;
        dynamic tripId;
        dynamic vehicleId;
        dynamic latitude;
        dynamic longitude;
        String companyName;
        String carrier;
        String carrierAddress;
        String homeTerminal;
        dynamic entryTime;
        dynamic exitTime;
        bool is16HourExceptionEnabled;
        String driverSignImageUrl;
        int drivingSpeed;
        int drivingMinute;
        int onDutySpeed;
        int onDutyMinute;
        int offDutySpeed;
        int offDutyMinute;
        int driverId;
        String deviceId;
        int teamDriverType;

        DriverDetail({
            this.companyId,
            this.driverName,
            this.loadId,
            this.cancelReason,
            this.availableTask,
            this.tripId,
            this.vehicleId,
            this.latitude,
            this.longitude,
            this.companyName,
            this.carrier,
            this.carrierAddress,
            this.homeTerminal,
            this.entryTime,
            this.exitTime,
            this.is16HourExceptionEnabled,
            this.driverSignImageUrl,
            this.drivingSpeed,
            this.drivingMinute,
            this.onDutySpeed,
            this.onDutyMinute,
            this.offDutySpeed,
            this.offDutyMinute,
            this.driverId,
            this.deviceId,
            this.teamDriverType,
        });

        factory DriverDetail.fromJson(Map json) => DriverDetail(
            companyId: json("CompanyId"),
            driverName: json("DriverName"),
            loadId: json("LoadId"),
            cancelReason: json("CancelReason"),
            availableTask: json("AvailableTask"),
            tripId: json("TripId"),
            vehicleId: json("VehicleId"),
            latitude: json("Latitude"),
            longitude: json("Longitude"),
            companyName: json("CompanyName"),
            carrier: json("Carrier"),
            carrierAddress: json("CarrierAddress"),
            homeTerminal: json("HomeTerminal"),
            entryTime: json("EntryTime"),
            exitTime: json("ExitTime"),
            is16HourExceptionEnabled: json("is16HourExceptionEnabled"),
            driverSignImageUrl: json("DriverSignImageUrl"),
            drivingSpeed: json("DrivingSpeed"),
            drivingMinute: json("DrivingMinute"),
            onDutySpeed: json("OnDutySpeed"),
            onDutyMinute: json("OnDutyMinute"),
            offDutySpeed: json("OffDutySpeed"),
            offDutyMinute: json("OffDutyMinute"),
            driverId: json("DriverId"),
            deviceId: json("DeviceId"),
            teamDriverType: json("TeamDriverType"),
        );

        Map toJson() => {
            "CompanyId": companyId,
            "DriverName": driverName,
            "LoadId": loadId,
            "CancelReason": cancelReason,
            "AvailableTask": availableTask,
            "TripId": tripId,
            "VehicleId": vehicleId,
            "Latitude": latitude,
            "Longitude": longitude,
            "CompanyName": companyName,
            "Carrier": carrier,
            "CarrierAddress": carrierAddress,
            "HomeTerminal": homeTerminal,
            "EntryTime": entryTime,
            "ExitTime": exitTime,
            "is16HourExceptionEnabled": is16HourExceptionEnabled,
            "DriverSignImageUrl": driverSignImageUrl,
            "DrivingSpeed": drivingSpeed,
            "DrivingMinute": drivingMinute,
            "OnDutySpeed": onDutySpeed,
            "OnDutyMinute": onDutyMinute,
            "OffDutySpeed": offDutySpeed,
            "OffDutyMinute": offDutyMinute,
            "DriverId": driverId,
            "DeviceId": deviceId,
            "TeamDriverType": teamDriverType,
        };
    }

    class DriverPermission {
        int driverPermissionId;
        int driverId;
        dynamic driverName;
        int getApiDelayCount;
        bool isCertifyMandatory;
        bool offDuty;
        bool sleeper;
        bool driving;
        bool onDuty;
        bool location;
        DateTime createdDate;
        int viewCertifyDays;
        int editDays;
        bool sendLog;
        bool odometerFromObd;
        int companyId;

        DriverPermission({
            this.driverPermissionId,
            this.driverId,
            this.driverName,
            this.getApiDelayCount,
            this.isCertifyMandatory,
            this.offDuty,
            this.sleeper,
            this.driving,
            this.onDuty,
            this.location,
            this.createdDate,
            this.viewCertifyDays,
            this.editDays,
            this.sendLog,
            this.odometerFromObd,
            this.companyId,
        });

        factory DriverPermission.fromJson(Map json) => DriverPermission(
            driverPermissionId: json("DriverPermissionId"),
            driverId: json("DriverId"),
            driverName: json("DriverName"),
            getApiDelayCount: json("GetApiDelayCount"),
            isCertifyMandatory: json("IsCertifyMandatory"),
            offDuty: json("OffDuty"),
            sleeper: json("Sleeper"),
            driving: json("Driving"),
            onDuty: json("OnDuty"),
            location: json("Location"),
            createdDate: DateTime.parse(json("CreatedDate")),
            viewCertifyDays: json("ViewCertifyDays"),
            editDays: json("EditDays"),
            sendLog: json("SendLog"),
            odometerFromObd: json("OdometerFromOBD"),
            companyId: json("CompanyId"),
        );

        Map toJson() => {
            "DriverPermissionId": driverPermissionId,
            "DriverId": driverId,
            "DriverName": driverName,
            "GetApiDelayCount": getApiDelayCount,
            "IsCertifyMandatory": isCertifyMandatory,
            "OffDuty": offDuty,
            "Sleeper": sleeper,
            "Driving": driving,
            "OnDuty": onDuty,
            "Location": location,
            "CreatedDate": createdDate.toIso8601String(),
            "ViewCertifyDays": viewCertifyDays,
            "EditDays": editDays,
            "SendLog": sendLog,
            "OdometerFromOBD": odometerFromObd,
            "CompanyId": companyId,
        };
    }

    class DriverSetting {
        String currentCycleName;
        int currentCycleId;
        int canadaCycleId;
        String caCycleName;
        List canadaCycles;
        int usaCycleId;
        String usaCycleName;
        List usaCycles;
        int timeZoneId;
        double offsetHours;
        String driverTimeZone;
        String timeZone;
        List lstTimeZone;
        List states;
        int driverId;
        dynamic deviceId;
        int teamDriverType;

        DriverSetting({
            this.currentCycleName,
            this.currentCycleId,
            this.canadaCycleId,
            this.caCycleName,
            this.canadaCycles,
            this.usaCycleId,
            this.usaCycleName,
            this.usaCycles,
            this.timeZoneId,
            this.offsetHours,
            this.driverTimeZone,
            this.timeZone,
            this.lstTimeZone,
            this.states,
            this.driverId,
            this.deviceId,
            this.teamDriverType,
        });

        factory DriverSetting.fromJson(Map json) => DriverSetting(
            currentCycleName: json("CurrentCycleName"),
            currentCycleId: json("CurrentCycleId"),
            canadaCycleId: json("CanadaCycleId"),
            caCycleName: json("CACycleName"),
            canadaCycles: List.from(json("CanadaCycles").map((x) => ACycle.fromJson(x))),
            usaCycleId: json("USACycleId"),
            usaCycleName: json("USACycleName"),
            usaCycles: List.from(json("USACycles").map((x) => ACycle.fromJson(x))),
            timeZoneId: json("TimeZoneID"),
            offsetHours: json("OffsetHours"),
            driverTimeZone: json("DriverTimeZone"),
            timeZone: json("TimeZone"),
            lstTimeZone: List.from(json("LstTimeZone").map((x) => LstTimeZone.fromJson(x))),
            states: List.from(json("States").map((x) => State.fromJson(x))),
            driverId: json("DriverId"),
            deviceId: json("DeviceId"),
            teamDriverType: json("TeamDriverType"),
        );

        Map toJson() => {
            "CurrentCycleName": currentCycleName,
            "CurrentCycleId": currentCycleId,
            "CanadaCycleId": canadaCycleId,
            "CACycleName": caCycleName,
            "CanadaCycles": List.from(canadaCycles.map((x) => x.toJson())),
            "USACycleId": usaCycleId,
            "USACycleName": usaCycleName,
            "USACycles": List.from(usaCycles.map((x) => x.toJson())),
            "TimeZoneID": timeZoneId,
            "OffsetHours": offsetHours,
            "DriverTimeZone": driverTimeZone,
            "TimeZone": timeZone,
            "LstTimeZone": List.from(lstTimeZone.map((x) => x.toJson())),
            "States": List.from(states.map((x) => x.toJson())),
            "DriverId": driverId,
            "DeviceId": deviceId,
            "TeamDriverType": teamDriverType,
        };
    }

    class ACycle {
        int eldCyclesId;
        String cycleName;

        ACycle({
            this.eldCyclesId,
            this.cycleName,
        });

        factory ACycle.fromJson(Map json) => ACycle(
            eldCyclesId: json("ELDCyclesId"),
            cycleName: json("CycleName"),
        );

        Map toJson() => {
            "ELDCyclesId": eldCyclesId,
            "CycleName": cycleName,
        };
    }

    class LstTimeZone {
        int timeZoneId;
        String timeZone;
        dynamic utc;
        String timeZoneName;
        dynamic timeZoneCity;

        LstTimeZone({
            this.timeZoneId,
            this.timeZone,
            this.utc,
            this.timeZoneName,
            this.timeZoneCity,
        });

        factory LstTimeZone.fromJson(Map json) => LstTimeZone(
            timeZoneId: json("TimeZoneID"),
            timeZone: json("TimeZone"),
            utc: json("UTC"),
            timeZoneName: json("TimeZoneName"),
            timeZoneCity: json("TimeZoneCity"),
        );

        Map toJson() => {
            "TimeZoneID": timeZoneId,
            "TimeZone": timeZone,
            "UTC": utc,
            "TimeZoneName": timeZoneName,
            "TimeZoneCity": timeZoneCity,
        };
    }

    class State {
        String stateName;
        String stateCode;
        Country country;

        State({
            this.stateName,
            this.stateCode,
            this.country,
        });

        factory State.fromJson(Map json) => State(
            stateName: json("StateName"),
            stateCode: json("StateCode"),
            country: countryValues.map(json("Country")),
        );

        Map toJson() => {
            "StateName": stateName,
            "StateCode": stateCode,
            "Country": countryValues.reverse(country),
        };
    }

    enum Country { USA, CANADA, MEXICO }

    final countryValues = EnumValues({
        "CANADA": Country.CANADA,
        "MEXICO": Country.MEXICO,
        "USA": Country.USA
    });

    class SupportDetail {
        int supportDetailId;
        String key;
        String value;
        int keyType;
        bool isActive;
        DateTime createdDate;
        DateTime modifiedDate;

        SupportDetail({
            this.supportDetailId,
            this.key,
            this.value,
            this.keyType,
            this.isActive,
            this.createdDate,
            this.modifiedDate,
        });

        factory SupportDetail.fromJson(Map json) => SupportDetail(
            supportDetailId: json("SupportDetailId"),
            key: json("Key"),
            value: json("Value"),
            keyType: json("KeyType"),
            isActive: json("IsActive"),
            createdDate: DateTime.parse(json("CreatedDate")),
            modifiedDate: json("ModifiedDate") == null ? null : DateTime.parse(json("ModifiedDate")),
        );

        Map toJson() => {
            "SupportDetailId": supportDetailId,
            "Key": key,
            "Value": value,
            "KeyType": keyType,
            "IsActive": isActive,
            "CreatedDate": createdDate.toIso8601String(),
            "ModifiedDate": modifiedDate == null ? null : modifiedDate.toIso8601String(),
        };
    }

    class EnumValues {
        Map map;
        Map reverseMap;

        EnumValues(this.map);

        Map get reverse {
            if (reverseMap == null) {
                reverseMap = map.map((k, v) => new MapEntry(v, k));
            }
            return reverseMap;
        }
    }


   This is my Database class

    import 'dart:convert';

    import 'package:als_e_100/modals/login_data.dart';
    import 'package:als_e_100/modals/login_modal.dart';
    import 'package:sqflite/sqflite.dart';
    import 'dart:io' as io;
    import 'package:path/path.dart';
    import 'package:path_provider/path_provider.dart';

    class DBHelper {
      static Database _db;
      Future get db async {
        if (_db != null) {
          return _db;
        }
        _db = await initDatabase();
        return _db;
      }

      get index => null;

      initDatabase() async {
        io.Directory documentDirectory = await getApplicationDocumentsDirectory();
        String path = join(documentDirectory.path, 'eldtable.db');
        var db = await openDatabase(path, version: 1, onCreate: _onCreate);
        return db;
      }

      _onCreate(Database db, int version) async {
        await db.execute('CREATE TABLE driverdetailList('
            'companyId INTEGER PRIMARY KEY,'
            'driverName TEXT,'

            ')');

        await db.execute('CREATE TABLE driversettings('
            'companyId INTEGER PRIMARY KEY,'
            'currentCycleName TEXT,'
            'currentCycleId INTEGER,'
            'canadaCycleId INTEGER,'
            'usaCycleId INTEGER,'
            'usaCycleName TEXT,'
            'driverTimeZone TEXT,'
            'timeZone TEXT,'
            'driverId INTEGER,'
            'deviceId INTEGER,'
            'teamDriverType INTEGER'
            ')');

        await db.execute('CREATE TABLE driversupportdetail('
            'companyId INTEGER PRIMARY KEY,'
            'supportDetailId INTEGER,'
            'keyType INTEGER,'
            'key TEXT,'
            'value TEXT,'
            'isActive INTEGER,'
            'createdDate TEXT,'
            'modifiedDate TEXT'
            ')');

        await db.execute('CREATE TABLE driverpermission('
            'companyId INTEGER PRIMARY KEY,'
            'driverPermissionId INTEGER,'
            'driverId INTEGER,'
            'driverName TEXT,'
            'getApiDelayCount INTEGER,'
            'isCertifyMandatory TEXT,'
            'offDuty TEXT,'
            'sleeper INTEGER,'
            'driving INTEGER,'
            'onDuty TEXT,'
            'location INTEGER,'
            'createdDate NUMERIC,'
            'viewCertifyDays INTEGER,'
            'sendLog INTEGER,'
            'editDays INTEGER,'
            'odometerFromObd INTEGER'

            ')');

        await db.execute('CREATE TABLE accycle('
            'companyId INTEGER PRIMARY KEY,'
            'eldCyclesId INTEGER,'
            'cycleName TEXT'
            ')');

        await db.execute('CREATE TABLE timezone('
            'companyId INTEGER PRIMARY KEY,'
            'timeZoneId INTEGER,'
            'timeZone TEXT,'
            'utc TEXT,'
            'timeZoneName TEXT,'
            'timeZoneCity INTEGER'
            ')');

        await db.execute('CREATE TABLE state('
            'companyId INTEGER PRIMARY KEY,'
            'stateCode TEXT,'
            'stateName TEXT,'
            'country TEXT'
            ')');

        await db.execute('CREATE TABLE logindata('
            'companyId INTEGER PRIMARY KEY,'
            'FOREIGN KEY(companyId) REFERENCES driverdetailList(companyId),'
            'FOREIGN KEY(companyId) REFERENCES driversettings(companyId)'
            'FOREIGN KEY(companyId) REFERENCES driversupportdetail(companyId),'
            'FOREIGN KEY(companyId) REFERENCES driverpermission(companyId)'
            'FOREIGN KEY(companyId) REFERENCES accycle(companyId),'
            'FOREIGN KEY(companyId) REFERENCES timezone(companyId)'
            'FOREIGN KEY(companyId) REFERENCES state(companyId)'
            ')');

        await db.execute('CREATE TABLE login('
            'companyId INTEGER PRIMARY KEY,'
            'message TEXT,'
            'status INTEGER,'
            'FOREIGN KEY(companyId) REFERENCES logindata(companyId)' //sdhgfjksd
            ')');
      }

      add(LoginModal loginModal) async {
        var dbClient = await db;
        var raw = await dbClient.insert('login', loginModal.toJson());


        return raw;
      }


      Future> getLogin() async {
        var dbClient = await db;

        List maps = await dbClient.rawQuery('SELECT * FROM login');
        List addUrlTable =
            maps.isNotEmpty ? maps.map((f) => LoginModal.fromJson(f)).toList() : ();
        return addUrlTable;

      }

      Future delete(int id) async {
        var dbClient = await db;
        return await dbClient.delete(
          'login',
          where: 'id = ?',
          whereArgs: (id),
        );
      }

      Future update(LoginModal loginModal) async {
        var dbClient = await db;
        return await dbClient.update(
          'login',
          loginModal.toJson(),
          where: 'id = ?',
          // whereArgs: (loginModal.data(index).driverDetail.companyId),
        );
      }

      Future close() async {
        var dbClient = await db;
        dbClient.close();
      }
    }

View custom post-type relationships by taxonomy

I have two custom post types, Product and Review.
The & # 39; Products & # 39; have a custom taxonomy & # 39; fruits & # 39; with the terms & # 39; apples & # 39; and & # 39; bananas & # 39 ;.

All "Review" have a custom field that is related to "Product" so I can easily select the product to review (using ACF). For example, I could add a review post called "Granny Smith Review" and select the product "Granny Smith".

In my navigation bar I have a link called "Ratings" that points to this URL: blabla.com/review and my archive-review.php successfully lists all reviews.

Question:
Is it possible to have a referenced URL? blabla.com/review/fruits/apples or blabla.com/review/apples So I can have a dropdown menu called "apples" that only shows "review" with the term "apple" (this is the taxonomy for the "product")

Or if you know a more skillful way of structuring things, I'd be happy to hear! Because it feels like I have a lot of duplicate posts. But what is important is that I have the "Review / Fruits / Apples" or "Review / Apples" slug.

I am a new developer and would appreciate any feedback, thanks! 🙂

Custom post-type ad and works empty Quick Edit

I have a puzzle problem. I have successfully created a custom post type with associated categories. BUT when I list the posts, the "QuickEdit" section does not display the title, date, or information. It's empty and I do not know why. Can someone see the problem?

//////////////////////// setup admin pages
add_action( 'init', 'mmd_client_tracking_form', 0 );                            // Add the menu
function mmd_client_tracking_form()
{
  $labels = array(
    'name'               => _x( 'Review Client Workouts', 'mmd_client_list' ),
    'singular_name'      => _x( 'Manage Clients', 'mmd_client_list' ),
    'add_new'            => _x( 'New Client', 'mmd_client_list' ),
    'add_new_item'       => __( 'Add New Client' ),
    'edit_item'          => __( 'Edit Client' ),
    'new_item'           => __( 'New Client' ),
    'all_items'          => __( 'Workout Clients' ),
    'view_item'          => __( 'View Client' ),
    'search_items'       => __( 'Search Clients' ),
    'not_found'          => __( 'No Clients found' ),
    'not_found_in_trash' => __( 'No Clients found in the Trash' ), 
    'parent_item_colon'  => '',
    'menu_name'          => 'Biorider Tracking'
  );


  $args = array(
    'register_meta_box_cb' => 'mmdtrack_meta_box', // Register a meta box
    'labels'               => $labels,
    'description'          => 'This post type holds all posts for your directory items.',
    'public'               => true,
    'menu_position'        => 10,
    'show_ui'              => true,
    'supports'             => array( 'title' ),
    'has_archive'          => true,
    'menu_icon'            => 'dashicons-media-spreadsheet',
  );
  register_post_type( 'mmdtrack', $args );  

}


//-----------------------------------------------------------------
// CUSTOM CATAGORY
//-----------------------------------------------------------------
add_action( 'init', 'mmd_track_taxonomies', 0 );                                  // Add the standard submenu
function mmd_track_taxonomies() {

  $labels = array(
        'name'              => _x( 'Biorider Categories', 'Biorider Categories' ),
        'singular_name'     => _x( 'Category', 'taxonomy singular name' ),
        'search_items'      => __( 'Search Clients Categories' ),
        'all_items'         => __( 'All Clients Categories' ),
        'parent_item'       => __( 'Parent Clients Categories' ),
        'parent_item_colon' => __( 'Parent Clients Category:' ),
        'edit_item'         => __( 'Edit Clients Category' ),
        'update_item'       => __( 'Update Clients Category' ),
        'add_new_item'      => __( 'Add New Clients Category' ),
        'new_item_name'     => __( 'New Clients Category Name' ),
        'menu_name'         => __( 'Clients Categories')
  );
  $args = array(
        'hierarchical'      => true,
        'labels'            => $labels,
        'show_ui'           => true,
        'show_admin_column' => true,
        'query_var'         => true,
        'rewrite'           => array( 'slug' => 'mmdtrack_cat' )
  );

  register_taxonomy( 'mmdtrack_cat', 'mmdtrack', $args );
}

add_action( 'init', 'mmd_tracking_menu', 0 );                                          // Add the standard submenu
function mmd_tracking_menu()
{

add_submenu_page('edit.php?post_type=mmdtrack',   // Parent Slug from add_menu_page 
                 'Biorider Settings',             // Title of page
                 'Settings',                      // Menu title
                 'manage_options',                // Minimum capability to view the menu.
                 'mmd_Tracking_Settings_slug',    // Unqiue Slug Name
                 'mmd_trackingAdminPage' );    // A callback function used to display page content. 

}





//-----------------------------------------------------------------
// ENTRIES OF MEMBER LISTINGS - MANUAL
//-----------------------------------------------------------------
function mmdtrack_meta_box(WP_Post $post)
 { 
 $prefix = 'mmdtrack';                               // Custom Post Name    
 add_meta_box($prefix, 'Set Tracking', mmdtrack_client_tracking_form);  
 }

function  mmdtrack_client_tracking_form($PostId)
{
... displaying code for metabox
}



////////////////////////////////////////////////////////////////////////
//  THIS HOOKS IN TO WORDPRESS CUSTOM POST AND CHANGES THE 
//  MANAGE LIST FORM
//////////////////////////////////////////////////////////////////////
add_filter('manage_mmdtrack_posts_columns', 'mmd_member_track_columns_head');
function mmd_member_track_columns_head($defaults) {

    $new_columns('cb') = '';
    $new_columns('mmd_member_name')                    = 'Name';
    $new_columns('mmd_member_tracking_workout_count')  = 'Number of Workouts';
    $new_columns('mmd_member_memberships')             = 'Active Membershps';
    $new_columns('mmd_member_category')                = 'Categories';

    return $new_columns;
}



add_action('manage_mmdtrack_posts_custom_column', 'mmd_track_columns_content', 10, 2);
function mmd_track_columns_content($column_name, $post_ID)
{

switch($column_name)
 {  
  case 'mmd_member_name': 
      $Name  = get_the_title( $post_ID );
      echo $Name;
  break;

  case 'mmd_member_tracking_workout_count':
     $user_ID = mmd_track_FindUser($post_ID);
     echo mmd_track_GetWorkoutCnt($user_ID);
  break;

   case 'mmd_member_memberships':
     $user_ID = mmd_track_FindUser($post_ID);
     if($user_ID==0)
       echo "None";
  break;

  case 'mmd_member_category':
    $terms = get_the_terms( $post_ID, 'mmdtrack_cat' );

    /* If terms were found. */
    if ( !empty( $terms ) ) 
        {
        $out = array();

        /* Loop through each term, linking to the 'edit posts' page for the specific term. */
        foreach ( $terms as $term ) 
           {
           $out() = sprintf( '%s',
                    esc_url( add_query_arg( array( 'post_type' => 'mmdtrack', 'mmdtrack_cat' => $term->slug ), 'edit.php' ) ),
                    esc_html( sanitize_term_field( 'name', $term->name, $term->term_id, 'mmdtrack_cat', 'display' ) )
                           );
           }

         /* Join the terms, separating them with a comma. */
         echo join( ', ', $out );
        }

  break;        

 }
}






function mmd_track_emptytrash($post_ID)
{
if(get_post_status( $post_id ) === 'trash') 
  ClearMemberWorkouts($post_ID);

return 0;       
}
add_action( 'before_delete_post', 'mmd_track_emptytrash');

////////////////////////////////////////////////////////////
//  If a list is trashed, make sure all the list records are
//  removed from the table.
////////////////////////////////////////////////////////////
function mmd_track_place_in_trash($post_ID)
{
}
add_action('wp_trash_post', 'mmd_track_place_in_trash');



categories – redirect category parameters to the post-type archive

I try to filter categories by Post-Type,

e.g.: The following URI gets everyone post from the category news,

https://example.com/category/news/?post_type=post.

To update the main query:

function gpc_filter_categories( WP_Query $query ) {
    if ( is_admin() || ! $query->is_main_query() ) {
        return $query;
    }

    if ( isset( $_GET('post_type') ) ) {
        $get = esc_sql( $_GET('post_type') );
        $query->set( 'post_type', $get );
    }

    return $query;
}

add_action( 'pre_get_posts', 'gpc_filter_categories' );

That actually works great.

But here is the problem: it does not work with custom post type,
Let's say I have a post type named movie,

When accessing the following URI, the archive.php template is used instead of category.php,

https://example.com/category/news/?post_type=movie.

How do I insert a custom taxonomy into a custom post-type permalink?

I have a custom taxonomy called campaign and a custom post type called asset, For assets, I would like to have the following permalink structure: mysite.com//, I've achieved this through the following code, but now when I go to a normal page with the URL structure mysite.com/ there is a 404. And if I comment out the override part in the function to register the custom post type, or add that instead ams/%campaign%works, but that's not the URL structure I want for my custom post type.

Code to register the custom taxonomy:

...
'rewrite' => array(
    'slug' => '',
    'with_front' => true,
),
...

Code to register a custom contribution type:

...
rewrite' => array(
    'slug' => '%campaign%',
    'with_front' => true,
),
...

Rewriting functions:

function ams_asset_add_rewrite_rules( $rules ) {
    global $post;
    if ($post->post_type == 'asset' ) {
        $new = array();
        $new('((^/)+)/(.+)/?$') = 'index.php?asset=$matches(2)';
        $new('(.+)/?$') = 'index.php?campaign=$matches(1)';
        return array_merge( $new, $rules );
    }
    return $rules;
}
add_filter( 'rewrite_rules_array', 'ams_asset_add_rewrite_rules' );

// Handle the '%campaign%' URL placeholder
function ams_asset_filter_post_type_link( $link, $post = 0 ) {
    if ( $post->post_type == 'asset' ) {
        $cats = wp_get_object_terms( $post->ID, 'campaign' );
        if ( $cats ) {
            $link = str_replace( '%campaign%', $cats(0)->slug, $link );
        }
    }
    return $link;
}
add_filter( 'post_type_link', 'ams_asset_filter_post_type_link', 10, 2 );

Custom Post Types – How to have a dynamic slug and render the archive {post_type} .php?

So I have a custom post type named network and the name company_category for the custom taxonomy. Everything is fine until I can no longer render http: // localhost / digitalhxstaging / company. Both the company category and the company are all good, with the exception of archive-network.php. I've tried to remove the dynamic slug and how it works, but now my company category and company post are not showing the correct link. Please help me. I hope that makes sense. Below is the code with post link function.

public function company_post_type () {
$ labels = array (
& # 39; name & # 39; => _x (& # 39; company & # 39 ;, company & # 39 ;, & # 39; dhx-portal & # 39;),
& # 39; # 39 & singular_name; => _x (& # 39; company & # 39 ;, & # 39 ;, & # 39; dhx-portal & # 39;),
& # 39; # 39 & menu_name; => _x (& # 39; companies & # 39; companies & # 39 ;, dhx-portal & # 39;),
& # 39; # 39 & name_admin_bar; => _x (& # 39; company & # 39; company & # 39 ;, dhx-portal & # 39;),
& # 39; # 39 & add_new; => __ (& # 39; Add New & # 39 ;, dhx-portal & # 39;),
& # 39; # 39 & add_new_item; => __ (& # 39; add new company & # 39 ;, dhx-portal & # 39;),
& # 39; # 39 & new_item; => __ (& # 39; New Company & # 39 ;, & # 39; dhx-portal & # 39;),
& # 39; # 39 & edit_item; => __ (& # 39; edit company & # 39 ;, dhx-portal & # 39;),
& # 39; # 39 & view_item; => __ (& # 39; View Company & # 39 ;, dhx-portal & # 39;),
& # 39; # 39 & all_items; => __ (& # 39; all companies & # 39 ;, dhx-portal & # 39;),
& # 39; # 39 & search_items; => __ (& # 39; search companys & # 39 ;, dhx-portal & # 39;),
& # 39; # 39 & parent_item_colon; => __ (& # 39; parent: & # 39 ;, dhx-portal & # 39;),
& # 39; # 39 & not_found; => __ (& # 39; no company found. & # 39 ;, dhx-portal & # 39;),
& # 39; # 39 & not_found_in_trash; => __ (& # 39; No company found in Recycle Bin. & # 39 ;, dhx-portal & # 39;),
& # 39; # 39 & featured_image; => _x (& # 39; Company Cover Image & # 39 ;, & # 39; overrides the phrase & # 39; Featured Image & # 39; for this post type. Added in 4.3 & # 39; dhx-portal & & gt; # 39),
& # 39; # 39 & set_featured_image; => _x (& # 39; Define Title Picture & # 39 ;, & # 39; Overrides the phrase "Set Selected Picture" for this post type. Added in 4.3 & # 39; dhx-portal & # 39 ;,
& # 39; # 39 & remove_featured_image; => _x (& # 39; Remove Cover Image & # 39 ;, & # 39; Overrides the "Remove Selected Image" phrase for this post type. Added in 4.3 & # 39 ;, dhx-portal & # 39;
& # 39; # 39 & use_featured_image; => _x (& # 39; Use as title image & # 39 ;, & # 39; Overrides the phrase "Use as featured image" for this post type. Added in 4.3, & # 39; dhx-portal & # 39;
& # 39; # 39 & archives; => _x (& # 39; Company archives & # 39 ;, & # 39; The Post Type Archive label used in navigation menus, Default "Post Archives." Added in 4.4 & 39 ;, & # 39; dhx-portal & # 39 ),
& # 39; # 39 & insert_into_item; => _x (& # 39; Insert in company & # 39 ;, & # 39; Overrides the expression & # 39; Insert in post & # 39; / & # 39; Add in page & # 39; (when inserting media used in a post). Added in 4.4 & # 39 ;, dhx-portal & # 39 ;,
& # 39; # 39 & uploaded_to_this_item; => _x ("Uploaded to this company", "Overrides the Uploaded to this post" / "Uploaded to this page") (used when viewing attached media). Added in 4.4 & # 39 ;, dhx-portal & # 39; )
& # 39; # 39 & filter_items_list; => _x (& # 39; Filter companies list & # 39 ;, & # 39; screen reader text for the filter link header in the list of post types screen Default setting: Filter posts list / Filter pages list Added in 4.4 & # 39 ;, & # 39; dhx portal & # 39;),
& # 39; # 39 & items_list_navigation; => _x (& # 39; company list navigation & # 39 ;, & # 39; screen reader text for the pagination heading on the list of post types list. Default Posting List Navigation / Page Navigation default. Added in 4.4 & '; & # 39; dhx-portal & # 39;),
& # 39; # 39 & items_list; => _x (& # 39 ;, company list & # 39 ;, & # 39; screen reader text for the item list heading on the list of post types default setting "Post List" / "Page List" added in 4.4 & # 39, & # 39; # 39 & textdomain),
);

$ args = array (
& # 39; labels & # 39; => $ labels,
& # 39; # 39 & taxonomies; => array (& # 39; company_category & # 39;),
& # 39; public & # 39; => true,
& # 39; # 39 & publicly_queryable; => true,
& # 39; # 39 & show_ui; => true,
& # 39; # 39 & show_in_menu; => true,
& # 39; # 39 & menu_position; => 5,
& # 39; # 39 & menu_icon; => & # 39; dashicons-building & # 39 ;,
& # 39; rewrite & # 39; => array (& # 39; slug & # 39; => & # 39; company /% company_category% & # 39 ;, & # 39; with_front & # 39;;> false),
& # 39; # 39 & query_var; => true,
& # 39; # 39 & capacity_type; => & # 39; post & # 39 ;,
& # 39; # 39 & has_archive; => true,
& # 39; hierarchically & # 39; => true,
& # 39; supported & # 39; => array (& # 39; title & # 39 ;, & # 39; author & # 39 ;, custom fields & # 39;
);

register_post_type (& # 39; network & # 39 ;, $ args);
flush_rewrite_rules ();
}

/ **
* Company-specific taxonomy
* @since 0.1.0
* @access public
* /
public function company_taxonomy () {

$ labels = array (
& # 39; name & # 39; => __ (& # 39; enterprise categories & # 39 ;, & # 39; dhx-portal & # 39;),
& # 39; # 39 & singular_name; => __ (& # 39; Category & # 39 ;, & # 39; dhx-portal & # 39;),
& # 39; # 39 & search_items; => __ (& # 39; search categories & # 39 ;, dhx-portal & # 39;),
& # 39; # 39 & all_items; => __ (& # 39; All categories & # 39 ;, & # 39; dhx-portal & # 39;),
& # 39; # 39 & parent_item; => __ (& # 39; Parent & # 39 ;, & # 39; dhx-portal & # 39;),
& # 39; # 39 & parent_item_colon; => __ (& # 39; Parent: & # 39 ;, & # 39; dhx-portal & # 39;),
& # 39; # 39 & edit_item; => __ (& # 39; edit category & # 39 ;, & # 39; dhx-portal & # 39;),
& # 39; # 39 & update_item; => __ (& # 39; Update Category & # 39 ;, & # 39; dhx-portal & # 39;),
& # 39; # 39 & add_new_item; => __ (& # 39; add new category & # 39 ;, & # 39; dhx-portal & # 39;),
& # 39; # 39 & new_item_name; => __ (& # 39; new category & # 39 ;, & # 39; dhx-portal & # 39;),
& # 39; # 39 & menu_name; => __ (& # 39; Categories & # 39; dhx-portal & # 39;),
);

$ args = array (
& # 39; hierarchically & # 39; => true,
& # 39; labels & # 39; => $ labels,
& # 39; # 39 & show_ui; => true,
& # 39; # 39 & show_admin_column; => true,
& # 39; # 39 & query_var; => true,
& # 39; rewrite & # 39; => array (& # 39; slug & # 39; => & # 39; company & # 39 ;, with #front & # 39; => false),
);

register_taxonomy (& # 39; company_category & # 39 ;, array (& # 39; company_category & # 39;), $ args);
flush_rewrite_rules ();
}

/ **
* Company Permalink
* @since 0.1.0
* @access public
* /
public function company_post_link ($ post_link, $ id = 0) {
$ post = get_post ($ id);
if (is_object ($ post)) {
$ terms = wp_get_object_terms ($ post-> ID, & # 39; company_category & # 39;);
if ($ terms) {
return str_replace (& # 39;% company_category% & # 39 ;, $ terms[0]-> snail, $ post_link);
}
}
return $ post_link;
}

Here is the correct URL that works

enter Here is the correct URL that works

Let me know what you think. I only need http: // localhost / digitalhxstaging / company to work

custom post types – disabling post_type in URL

When you register your custom post type, tell WP if it's a CPT public_queryable,

And that argument says …:

Whether queries can be run as part of frontend
parse_request ().

Default: value of the public argument

Note: The queries
affected are the following ones (also initiated when rewrite
handled)

  • post_type = {post_type_key}
  • ? {post_type_key} = {single_post_slug}
  • ? {post_type_query_var} = {single_post_slug}

So if you do not want these posts to be queried, you should submit them not correct as this argument.