wp query – custom post-type not pulling posts in wordpress

I have a function in php as shown below in which I want to pull posts in wordpress with the post_type hello-world.

function area_search( $abc ) {
        if ( $abc ) {
            $query = new WP_Query( (
                's'           => $abc,
                'post_type'   => 'hello-world',
                'post_status' => 'publish',
            ) );
        } else {
            $query = new WP_Query( (
                'post_type'   => 'hello-world',
                'post_status' => 'publish',
                'ep_integrate' => true,
                'orderby' => 'title',
                'order'   => 'ASC',
            ) );
        }
        $result = array_map( __NAMESPACE__ . 'abc_xyz', $query->posts );
        echo '<pre>'; print_r($result); echo '</pre>'; // Line A
        return group( $result );
    }

function abc_xyz( $post ) {
    return $post->post_meta;
}

Here $abc is the keyword which user’s enter in the Search Posts section of the wordpress in the hello-world post-type.

I’ve added Line A in the function but unfortunately its printing an empty array:

Array
(
    (0) => 
    (1) => 
    (2) => 
    (3) => 
    (4) => 
    (5) => 
    (6) => 
    (7) => 
    (8) => 
)

Problem Statement:

The above code works perfectly fine in production environment in comparison to development environment.

I am wondering what changes I should make in the wordpress because the code works perfectly fine in production so I believe there is an issue
in wordpress not in the code above.

wp query – Question: How can I retrieve the post details liked by the current_user using the post_id from the “Different” post_type?

I am soo new to WordPress development, so I am so lost in this.

I have a custom post type “Like” that automatically adds the post_id of the page/post the user liked, and the “Like” post type contains only the post_id, nothing else.

So, my “Post” and “Like” has one common denominator which is the “Post” post_id.

I want to list/retrieve all the posts liked by the current user in a different page and the only code I can get in mind is this;

    'post_type' => 'like',
    'author' => get_current_user_id(),
    'meta_query'=> array(
        'key' => 'liked_post_id',
        'compare' => '=',
        'value' => get_the_ID() // this returns the ID of the page/post the user liked

)

));```

I hope someone can help me with this. :)

custom post types – Trying to get a multi select post_type list

I’m trying to create a multi-select list of a custom post_type for another custom post_type metabox.

But I can’t even generate an array of the post type using get_pages. I’ve tried the following code but it doesn’t seem to be working:

$_options = get_pages( $_args );

$_args array –

Array
(
    (post_type) => publications
    (parent) => 0
    (hierarchical) => false
)

It’s returning an empty array. Any help would be greatly appreciated!

PHP – Get all custom post-type taxonomies, but exclude them by name

I have 2 custom post types and 1 taxonomy has been added to each, but I want an array that gets 1 taxonomy from each CPT and displays it normally.

I have this code that retrieves each taxonomy from 1 post type:

 //Array of taxonomies to get terms for
$taxonomies = array('category','post_tags','my-tax');
//Set arguments - don't 'hide' empty terms.
$args = array(
 'hide_empty' => 0
);

$terms = get_terms( $taxonomies, $args);
$empty_terms=array();

foreach( $terms as $term ){
 if( 0 == $term->count )
      $empty_terms() = $term;

}

However, I only want to target 1 taxonomy from each CPT, for example:

Post 1 – Taglist1
Post 2 – Taglist2

is displayed in a foreach if this makes sense. Does anyone have a solution for this?

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');