{"id":4236,"date":"2022-08-22T01:01:25","date_gmt":"2022-08-21T19:31:25","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-modifying-wordpress-core-files\/"},"modified":"2022-08-22T01:01:25","modified_gmt":"2022-08-21T19:31:25","slug":"solved-modifying-wordpress-core-files","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-modifying-wordpress-core-files\/","title":{"rendered":"[Solved] Modifying WordPress core files"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-1586\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"1586\" data-parentid=\"1564\" data-score=\"20\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<p>If you <em>must<\/em> hack core, consider doing so in a way that makes it extensible for others.<\/p>\n<h3>Add an Action Hook<\/h3>\n<p>Nine times out of ten, you could do what it is you wanted if only there was an extra <code>do_action<\/code> call in a specific file.  In that case, add the action, document it, and <strong>submit a patch via <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/trac.wordpress.org\/\">Trac<\/a><\/strong>.  If there&#8217;s a good reason for your patch (i.e. you&#8217;re not the only one who would ever use it) then you can probably get it added to core.<\/p>\n<p>Next, build a custom plug-in (you don&#8217;t have to release\/distribute it!) that ties in to this new hook and performs whatever function you need it to do.<\/p>\n<h3>Refactor a core file<\/h3>\n<p>Other times, you might just need a piece of code to behave differently.  Pass a variable by reference, for example, or return a value rather than echo it.  Take some time to sit down and refactor the code so it does what you need it to do &#8230; then <strong>submit a patch via <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/trac.wordpress.org\/\">Trac<\/a><\/strong> so the rest of us can benefit from your work.<\/p>\n<hr>\n<p>Do you see a theme developing here?  Hacking core isn&#8217;t necessarily a no-no &#8230; just something most developers will <strong><em>highly discourage<\/em><\/strong> for new users or novice programmers (if you&#8217;re asking us how to do something, we&#8217;ll suggest a plug-in every time before even considering to suggest you hack core).  <\/p>\n<p>Hacking core is the way WordPress develops and evolves, but it&#8217;s dangerous for someone just learning PHP or with no experience working with WP files.  Please start with a plug-in before touching core &#8211; if you break a plug-in you can uninstall it quickly (removing via FTP if necessary) &#8230; but if you break core, bad things can happen to your site and potentially to your database as well.<\/p>\n<p>But if you are in a situation where a core hack is unavoidable, then make the change.  Also, publish your change in a prominent location (if your blog is highly visible, that might be sufficient &#8230; but I suggest <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/trac.wordpress.org\/\">Trac<\/a> because that&#8217;s how community changes get pulled into the next release).  Your change might be the magic bullet that could fix problems in a hundred different sites &#8230; so contribute back to the community that helped you build your site.<\/p>\n<p>If the change gets committed, then your hack becomes part of core and you won&#8217;t need to worry about it in the future.  If it doesn&#8217;t, at least you have detailed documentation on how to re-implement the hack after you upgrade WP in 3 months.<\/p>\n<\/p><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\">1<\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved Modifying WordPress core files <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] If you must hack core, consider doing so in a way that makes it extensible for others. Add an Action Hook Nine times out of ten, you could do what it is you wanted if only there was an extra do_action call in a specific file. In that case, add the action, document it, &#8230; <a title=\"[Solved] Modifying WordPress core files\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-modifying-wordpress-core-files\/\" aria-label=\"More on [Solved] Modifying WordPress core files\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[627],"tags":[706],"class_list":["post-4236","post","type-post","status-publish","format-standard","hentry","category-wordpress","tag-core"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>[Solved] Modifying WordPress core files - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-modifying-wordpress-core-files\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] Modifying WordPress core files - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] If you must hack core, consider doing so in a way that makes it extensible for others. Add an Action Hook Nine times out of ten, you could do what it is you wanted if only there was an extra do_action call in a specific file. In that case, add the action, document it, ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-modifying-wordpress-core-files\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-08-21T19:31:25+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-modifying-wordpress-core-files\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-modifying-wordpress-core-files\\\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#\\\/schema\\\/person\\\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] Modifying WordPress core files\",\"datePublished\":\"2022-08-21T19:31:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-modifying-wordpress-core-files\\\/\"},\"wordCount\":443,\"publisher\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#organization\"},\"keywords\":[\"core\"],\"articleSection\":[\"WordPress\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-modifying-wordpress-core-files\\\/\",\"url\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-modifying-wordpress-core-files\\\/\",\"name\":\"[Solved] Modifying WordPress core files - JassWeb\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#website\"},\"datePublished\":\"2022-08-21T19:31:25+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-modifying-wordpress-core-files\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-modifying-wordpress-core-files\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-modifying-wordpress-core-files\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] Modifying WordPress core files\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#website\",\"url\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/jassweb.com\\\/wp-content\\\/uploads\\\/2021\\\/02\\\/jass-website-logo-1.png\",\"contentUrl\":\"https:\\\/\\\/jassweb.com\\\/wp-content\\\/uploads\\\/2021\\\/02\\\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#\\\/schema\\\/person\\\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/wp-content\\\/litespeed\\\/avatar\\\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777008400\",\"url\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/wp-content\\\/litespeed\\\/avatar\\\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777008400\",\"contentUrl\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/wp-content\\\/litespeed\\\/avatar\\\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777008400\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\\\/\\\/jassweb.com\"],\"url\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/author\\\/jaspritsinghghumangmail-com\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] Modifying WordPress core files - JassWeb","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jassweb.com\/solved\/solved-modifying-wordpress-core-files\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] Modifying WordPress core files - JassWeb","og_description":"[ad_1] If you must hack core, consider doing so in a way that makes it extensible for others. Add an Action Hook Nine times out of ten, you could do what it is you wanted if only there was an extra do_action call in a specific file. In that case, add the action, document it, ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-modifying-wordpress-core-files\/","og_site_name":"JassWeb","article_published_time":"2022-08-21T19:31:25+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-modifying-wordpress-core-files\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-modifying-wordpress-core-files\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] Modifying WordPress core files","datePublished":"2022-08-21T19:31:25+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-modifying-wordpress-core-files\/"},"wordCount":443,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["core"],"articleSection":["WordPress"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-modifying-wordpress-core-files\/","url":"https:\/\/jassweb.com\/solved\/solved-modifying-wordpress-core-files\/","name":"[Solved] Modifying WordPress core files - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2022-08-21T19:31:25+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-modifying-wordpress-core-files\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-modifying-wordpress-core-files\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-modifying-wordpress-core-files\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] Modifying WordPress core files"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777008400","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777008400","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777008400","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/4236","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=4236"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/4236\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=4236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=4236"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=4236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}