{"id":22970332,"url":"https://github.com/xenioushk/wordpress_101","last_synced_at":"2026-05-03T02:41:03.482Z","repository":{"id":268028356,"uuid":"850361418","full_name":"xenioushk/wordpress_101","owner":"xenioushk","description":"Useful WordPress functions, actions, hooks, wp-cli commands","archived":false,"fork":false,"pushed_at":"2025-03-26T02:50:20.000Z","size":167,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T06:14:01.610Z","etag":null,"topics":["wordpress","wordpress-developer","wordpress-development","wordpress-functions"],"latest_commit_sha":null,"homepage":"https://bluewindlab.net","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xenioushk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-31T15:01:37.000Z","updated_at":"2025-03-26T02:50:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"da88ca85-4b5c-4c74-92e8-d22004ab1e4a","html_url":"https://github.com/xenioushk/wordpress_101","commit_stats":null,"previous_names":["xenioushk/wordpress_101"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xenioushk/wordpress_101","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xenioushk%2Fwordpress_101","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xenioushk%2Fwordpress_101/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xenioushk%2Fwordpress_101/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xenioushk%2Fwordpress_101/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xenioushk","download_url":"https://codeload.github.com/xenioushk/wordpress_101/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xenioushk%2Fwordpress_101/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32556771,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T00:31:16.350Z","status":"online","status_checked_at":"2026-05-03T02:00:09.297Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["wordpress","wordpress-developer","wordpress-development","wordpress-functions"],"created_at":"2024-12-14T22:12:19.150Z","updated_at":"2026-05-03T02:41:03.456Z","avatar_url":"https://github.com/xenioushk.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Useful and frequently used WordPress functions.\n\n## ✅ WP-Cli Commands\n\n### Get wp-cli version\n\n```bash\nwp --info\n```\n\n### Update all the themes\n\n```bash\nwp theme update --all\n```\n\n### Create a new plugin\n\nNavigate to `wp-content/plugins/`. Then run this command to create a new plugin called `my-awesome-plugin`.\n\n```bash\nwp scaffold plugin my-awesome-plugin\n```\n\n![create_a_wordpress_plugin_with_wpcli](/previews/create_a_wordpress_plugin_with_wpcli.jpg)\n\n### Update all the plugins\n\n```bash\nwp plugin update --all\n```\n\n## ✅ Cron job \u0026 Transient API\n\nCheck this [example code](/AppCronManager.php).\n\n## ✅ Function comment style\n\n```php\n/**\n * List of views served by this composer.\n *\n * @var array\n * @return array\n */\n```\n\n## ✅ Shortcode Class example\n\n```php\nclass My_Shortcode{\n  public function __construct(){\n    $this-\u003eregister_shortcode();\n  }\n\n  public function register_shortcode(){\n    add_shortcode('shortcode_tag', [$this, 'get_shortcode_output']);\n  }\n\n  public function get_shortcode_output($atts){\n    return \"Hello world\";\n  }\n}\n\n// Initialize the class\nnew My_Shortcode();\n```\n\n## ✅ Allow custom post types to use theme templates\n\n👉 Open a template file for the currently active theme. Our targeted custom post types are 'bwl_kb' and 'portfolio'.\n\n👉 We would like to use full-width template for those post types. So, we have edited the `template-full-width.php` file and\nincluded the following code.\n\n👉 The `Template Post Type` section in the commented area is allowing the custom post types to use the `template-full-width.php` file.\n\n```php\n/**\n *\n * Template Name: Full Width Template\n * Template Post Type: post, page, bwl_kb, portfolio\n * The template for displaying the contents without any sidebar.\n *\n * @package BwlKdeskTheme\n */\n```\n\nNow, if you go to the add/edit page of the portfolio or bwl_kb, you will be able to use the full-width template. ,🚀\n\n![use_custom_post_type_theme_full_width_template](/previews/use_custom_post_type_theme_full_width_template.jpg)\n\n## ✅ Access REST-API end points\n\nJust change the text `petitions` to `posts` for displaying all the posts.\n\n### Get all CPT\n\nCheck all your CPT REST routes dynamically.\n\n```bash\nGET /wp-json/wp/v2\n```\n\n### All Petitions\n\nReturns a list of petition posts.\n\n```bash\nGET /wp-json/wp/v2/petitions\n```\n\n### Single Petition by ID\n\nReturns the petition post with ID 123.\n\n```bash\nGET /wp-json/wp/v2/petitions/123\n```\n\n### Filter by Custom Taxonomy (petitions_category)\n\nReturns petitions assigned to the petitions_category term ID 10.\n\n```bash\nGET /wp-json/wp/v2/petitions?petitions_category=10\n```\n\n### Pagination Example\n\nReturns the second page with 5 petitions per page.\n\n```bash\nGET /wp-json/wp/v2/petitions?per_page=5\u0026page=2\n```\n\n### Order by Date or Title\n\n```bash\nGET /wp-json/wp/v2/petitions?orderby=date\u0026order=desc\nGET /wp-json/wp/v2/petitions?orderby=title\u0026order=asc\n```\n\n### Search by Keyword\n\nReturns petitions that contain the keyword `child`.\n\n```bash\nGET /wp-json/wp/v2/petitions?search=child\n```\n\n### Filter by Meta Field (sign_count)\n\n```bash\nGET /wp-json/wp/v2/petitions?meta_key=sign_count\u0026orderby=meta_value_num\n```\n\n### Get Embedded Featured Images and Author\n\n`_embed` loads featured images, authors, and related objects to reduce additional calls.\n\n```bash\nGET /wp-json/wp/v2/petitions?_embed\n```\n\n## Expose the Meta Field to the REST API\n\nBy default, not all meta fields are available via REST API. You must register your `_cmb_bptm_sign_lists` meta key with `show_in_rest =\u003e true` when registering the meta.\n\n```php\nfunction register_petitions_meta() {\n    register_post_meta('petitions', '_cmb_bptm_sign_lists', [\n        'type'         =\u003e 'integer',\n        'single'       =\u003e true,\n        'show_in_rest' =\u003e true, //Must be true\n    ]);\n}\nadd_action('rest_api_init', 'register_petitions_meta');\n```\n\n![use_custom_post_type_theme_full_width_template](/previews/sign_lists_meta_field_count.jpg)\n\n🚧 **Important Note:**\n\nYou must need to enable `custom-fields` support while registering custom post type.\n\n```php\n$support = [ 'title', 'thumbnail', 'comments', 'author', 'editor', 'custom-fields' ];\n```\n\n![use_custom_post_type_theme_full_width_template](/previews/sign_lists_gutenburg_meta_count.jpg)\n\nNow, `_cmb_bptm_sign_lists` will be accessible as part of the `meta` object.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxenioushk%2Fwordpress_101","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxenioushk%2Fwordpress_101","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxenioushk%2Fwordpress_101/lists"}