{"id":1729,"date":"2024-02-02T20:58:20","date_gmt":"2024-02-02T19:58:20","guid":{"rendered":"https:\/\/yellotab.se\/x056\/?p=1729"},"modified":"2024-02-02T20:58:20","modified_gmt":"2024-02-02T19:58:20","slug":"first-wordpress-file","status":"publish","type":"post","link":"https:\/\/yellotab.se\/x056\/2024\/02\/02\/first-wordpress-file\/","title":{"rendered":"First wordpress file"},"content":{"rendered":"<div class=\"w-full text-token-text-primary\" data-testid=\"conversation-turn-2\">\n<div class=\"px-4 py-2 justify-center text-base md:gap-6 m-auto\">\n<div class=\"flex flex-1 text-base mx-auto gap-3 md:px-5 lg:px-1 xl:px-5 md:max-w-3xl lg:max-w-[40rem] xl:max-w-[48rem] group\">\n<div class=\"relative flex w-full flex-col lg:w-[calc(100%-115px)]\">\n<div class=\"flex-col gap-1 md:gap-3\">\n<div class=\"flex flex-grow flex-col max-w-full\">\n<div class=\"min-h-[20px] text-message flex flex-col items-start gap-3 whitespace-pre-wrap break-words [.text-message+&amp;]:mt-5 overflow-x-auto\" data-message-author-role=\"user\" data-message-id=\"aaa2e2e1-cd7b-4f02-b067-893f6c38bf85\">\n<div class=\"\">how to make wordpress page display json<\/div>\n<\/div>\n<\/div>\n<div class=\"mt-1 flex justify-start gap-3 empty:hidden\">\n<div class=\"text-gray-400 flex self-end lg:self-center justify-center lg:justify-start mt-0 -ml-1 visible\">\n<div class=\"flex items-center gap-1.5 text-xs\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"w-full text-token-text-primary\" data-testid=\"conversation-turn-3\">\n<div class=\"px-4 py-2 justify-center text-base md:gap-6 m-auto\">\n<div class=\"flex flex-1 text-base mx-auto gap-3 md:px-5 lg:px-1 xl:px-5 md:max-w-3xl lg:max-w-[40rem] xl:max-w-[48rem] group\">\n<div class=\"flex-shrink-0 flex flex-col relative items-end\">\n<div>\n<div class=\"pt-0.5\">\n<div class=\"gizmo-shadow-stroke flex h-6 w-6 items-center justify-center overflow-hidden rounded-full\">\n<div class=\"relative p-1 rounded-sm h-9 w-9 text-white flex items-center justify-center\">ChatGPT<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"relative flex w-full flex-col lg:w-[calc(100%-115px)] agent-turn\">\n<div class=\"font-semibold select-none\">ChatGPT<\/div>\n<div class=\"flex-col gap-1 md:gap-3\">\n<div class=\"flex flex-grow flex-col max-w-full\">\n<div class=\"min-h-[20px] text-message flex flex-col items-start gap-3 whitespace-pre-wrap break-words [.text-message+&amp;]:mt-5 overflow-x-auto\" data-message-author-role=\"assistant\" data-message-id=\"494bb404-cc5d-43ad-8254-9725319e95c3\">\n<div class=\"markdown prose w-full break-words dark:prose-invert light\">\n<p>If you want to display JSON data on a WordPress page, you can use a combination of custom code and plugins. Here&#8217;s a step-by-step guide:<\/p>\n<ol>\n<li><strong>Create a WordPress Page:<\/strong>\n<ul>\n<li>Log in to your WordPress admin dashboard.<\/li>\n<li>Navigate to &#8221;Pages&#8221; and create a new page or edit an existing one where you want to display JSON data.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Install a Plugin:<\/strong>\n<ul>\n<li>You can use a plugin to embed and display JSON data easily. One popular plugin for this purpose is &#8221;Embed Any Document&#8221;:\n<ul>\n<li>Go to &#8221;Plugins&#8221; &gt; &#8221;Add New&#8221; in your WordPress dashboard.<\/li>\n<li>Search for &#8221;Embed Any Document&#8221; and install it.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li><strong>Embed JSON File:<\/strong>\n<ul>\n<li>After installing the plugin, go to the page where you want to display JSON data.<\/li>\n<li>Use the &#8221;Add Document&#8221; button in the editor to embed your JSON file.<\/li>\n<li>Upload your JSON file or provide a direct link to it. The plugin will handle the display.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Custom Code (Optional):<\/strong>\n<ul>\n<li>If you want more control over the display or need to fetch and display dynamic JSON data, you can use custom code.<\/li>\n<li>Edit the page and switch to the HTML editor.<\/li>\n<li>Use HTML and JavaScript to fetch and display JSON data. You can use the <code class=\"\" data-line=\"\">fetch<\/code> API or jQuery for this purpose.<\/li>\n<\/ul>\n<div class=\"dark bg-black rounded-md\">\n<div class=\"flex items-center relative text-token-text-secondary bg-token-surface-primary px-4 py-2 text-xs font-sans justify-between rounded-t-md\">html<span class=\"\" data-state=\"closed\"><button class=\"flex gap-1 items-center\">Copy code<\/button><\/span><\/div>\n<div class=\"p-4 overflow-y-auto\"><code class=\"\" data-line=\"\">&lt;span class=&quot;hljs-tag&quot;&gt;&lt;&lt;span class=&quot;hljs-name&quot;&gt;div&lt;\/span&gt; &lt;span class=&quot;hljs-attr&quot;&gt;id&lt;\/span&gt;=&lt;span class=&quot;hljs-string&quot;&gt;&quot;json-container&quot;&lt;\/span&gt;&gt;&lt;\/span&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&lt;\/&lt;span class=&quot;hljs-name&quot;&gt;div&lt;\/span&gt;&gt;&lt;\/span&gt;<\/p>\n<p>&lt;span class=&quot;hljs-tag&quot;&gt;&lt;&lt;span class=&quot;hljs-name&quot;&gt;script&lt;\/span&gt;&gt;&lt;\/span&gt;&lt;span class=&quot;javascript&quot;&gt;<br \/>\n  &lt;span class=&quot;hljs-variable language_&quot;&gt;document&lt;\/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;addEventListener&lt;\/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&#039;DOMContentLoaded&#039;&lt;\/span&gt;, &lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;\/span&gt; () {<br \/>\n    &lt;span class=&quot;hljs-title function_&quot;&gt;fetch&lt;\/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&#039;your-json-endpoint-url&#039;&lt;\/span&gt;)<br \/>\n      .&lt;span class=&quot;hljs-title function_&quot;&gt;then&lt;\/span&gt;(&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-params&quot;&gt;response&lt;\/span&gt; =&gt;&lt;\/span&gt; response.&lt;span class=&quot;hljs-title function_&quot;&gt;json&lt;\/span&gt;())<br \/>\n      .&lt;span class=&quot;hljs-title function_&quot;&gt;then&lt;\/span&gt;(&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-params&quot;&gt;data&lt;\/span&gt; =&gt;&lt;\/span&gt; {<br \/>\n        &lt;span class=&quot;hljs-comment&quot;&gt;\/\/ Display JSON data in the specified container&lt;\/span&gt;<br \/>\n        &lt;span class=&quot;hljs-variable language_&quot;&gt;document&lt;\/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;getElementById&lt;\/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&#039;json-container&#039;&lt;\/span&gt;).&lt;span class=&quot;hljs-property&quot;&gt;innerHTML&lt;\/span&gt; = &lt;span class=&quot;hljs-title class_&quot;&gt;JSON&lt;\/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;stringify&lt;\/span&gt;(data, &lt;span class=&quot;hljs-literal&quot;&gt;null&lt;\/span&gt;, &lt;span class=&quot;hljs-number&quot;&gt;2&lt;\/span&gt;);<br \/>\n      })<br \/>\n      .&lt;span class=&quot;hljs-title function_&quot;&gt;catch&lt;\/span&gt;(&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-params&quot;&gt;error&lt;\/span&gt; =&gt;&lt;\/span&gt; &lt;span class=&quot;hljs-variable language_&quot;&gt;console&lt;\/span&gt;.&lt;span class=&quot;hljs-title function_&quot;&gt;error&lt;\/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&#039;Error fetching JSON:&#039;&lt;\/span&gt;, error));<br \/>\n  });<br \/>\n&lt;\/span&gt;&lt;span class=&quot;hljs-tag&quot;&gt;&lt;\/&lt;span class=&quot;hljs-name&quot;&gt;script&lt;\/span&gt;&gt;&lt;\/span&gt;<br \/>\n<\/code><\/div>\n<\/div>\n<ul>\n<li>Replace <code class=\"\" data-line=\"\">&#039;your-json-endpoint-url&#039;<\/code> with the actual URL or path to your JSON data.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Update and Preview:<\/strong>\n<ul>\n<li>Update the page, and preview it to see the JSON data displayed.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>Remember to properly format and validate your JSON data. If you&#8217;re fetching dynamic data, make sure your server supports Cross-Origin Resource Sharing (CORS) to prevent any security issues.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"mt-1 flex justify-start gap-3 empty:hidden\">\n<div class=\"text-gray-400 flex self-end lg:self-center justify-center lg:justify-start mt-0 -ml-1 visible\"><button class=\"flex items-center gap-1.5 rounded-md p-1 text-xs text-token-text-tertiary hover:text-token-text-primary md:invisible md:group-hover:visible md:group-[.final-completion]:visible\"><\/button><\/p>\n<div class=\"flex\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"w-full text-token-text-primary\" data-testid=\"conversation-turn-4\">\n<div class=\"px-4 py-2 justify-center text-base md:gap-6 m-auto\">\n<div class=\"flex flex-1 text-base mx-auto gap-3 md:px-5 lg:px-1 xl:px-5 md:max-w-3xl lg:max-w-[40rem] xl:max-w-[48rem] group\">\n<div class=\"flex-shrink-0 flex flex-col relative items-end\">\n<div>\n<div class=\"pt-0.5\">\n<div class=\"gizmo-shadow-stroke flex h-6 w-6 items-center justify-center overflow-hidden rounded-full\">\n<div class=\"relative flex\"><img loading=\"lazy\" decoding=\"async\" class=\"rounded-sm\" src=\"https:\/\/lh3.googleusercontent.com\/a\/AEdFTp5kCToIo5FGfvLjQcTlYkf3AuIVZw_8xqWtDU35Gw=s96-c\" alt=\"User\" width=\"24\" height=\"24\" data-nimg=\"1\" \/><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"relative flex w-full flex-col lg:w-[calc(100%-115px)]\">\n<div class=\"font-semibold select-none\">You<\/div>\n<div class=\"flex-col gap-1 md:gap-3\">\n<div class=\"flex flex-grow flex-col max-w-full\">\n<div class=\"min-h-[20px] text-message flex flex-col items-start gap-3 whitespace-pre-wrap break-words [.text-message+&amp;]:mt-5 overflow-x-auto\" data-message-author-role=\"user\" data-message-id=\"aaa2caab-5496-477c-ac00-8fc329ffa07e\">\n<div class=\"\">where to put a new file in wordpress<\/div>\n<\/div>\n<\/div>\n<div class=\"mt-1 flex justify-start gap-3 empty:hidden\">\n<div class=\"text-gray-400 flex self-end lg:self-center justify-center lg:justify-start mt-0 -ml-1 visible\">\n<div class=\"flex items-center gap-1.5 text-xs\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"w-full text-token-text-primary\" data-testid=\"conversation-turn-5\">\n<div class=\"px-4 py-2 justify-center text-base md:gap-6 m-auto\">\n<div class=\"flex flex-1 text-base mx-auto gap-3 md:px-5 lg:px-1 xl:px-5 md:max-w-3xl lg:max-w-[40rem] xl:max-w-[48rem] group\">\n<div class=\"flex-shrink-0 flex flex-col relative items-end\">\n<div>\n<div class=\"pt-0.5\">\n<div class=\"gizmo-shadow-stroke flex h-6 w-6 items-center justify-center overflow-hidden rounded-full\">\n<div class=\"relative p-1 rounded-sm h-9 w-9 text-white flex items-center justify-center\">ChatGPT<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"relative flex w-full flex-col lg:w-[calc(100%-115px)] agent-turn\">\n<div class=\"font-semibold select-none\">ChatGPT<\/div>\n<div class=\"flex-col gap-1 md:gap-3\">\n<div class=\"flex flex-grow flex-col max-w-full\">\n<div class=\"min-h-[20px] text-message flex flex-col items-start gap-3 whitespace-pre-wrap break-words [.text-message+&amp;]:mt-5 overflow-x-auto\" data-message-author-role=\"assistant\" data-message-id=\"9904691c-9255-4568-b301-d169a72793fd\">\n<div class=\"markdown prose w-full break-words dark:prose-invert light\">\n<p>In WordPress, the location where you should put a new file depends on its purpose and type. Here are common locations for different types of files:<\/p>\n<ol>\n<li><strong>Themes:<\/strong>\n<ul>\n<li>If the file is related to your theme, such as a custom template or stylesheet, you should place it within your theme folder.<\/li>\n<li>Navigate to the <code class=\"\" data-line=\"\">wp-content\/themes\/your-theme\/<\/code> directory, where &#8221;your-theme&#8221; is the folder name of your active theme.<\/li>\n<li>For example, if you want to add a custom stylesheet, you might create a file named <code class=\"\" data-line=\"\">custom.css<\/code> and place it in the theme folder.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Plugins:<\/strong>\n<ul>\n<li>If the file is related to a plugin, you should place it within the plugin&#8217;s folder.<\/li>\n<li>Navigate to the <code class=\"\" data-line=\"\">wp-content\/plugins\/your-plugin\/<\/code> directory, where &#8221;your-plugin&#8221; is the folder name of your plugin.<\/li>\n<li>For example, if your plugin needs an additional script, you might create a file named <code class=\"\" data-line=\"\">custom-script.js<\/code> and place it in the plugin folder.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Media Library:<\/strong>\n<ul>\n<li>If the file is a media file (image, audio, video, etc.), you can upload it directly to the WordPress Media Library.<\/li>\n<li>Go to the WordPress admin dashboard, navigate to &#8221;Media&#8221; and then &#8221;Add New.&#8221;<\/li>\n<li>Upload your file, and WordPress will store it in the appropriate folder in the <code class=\"\" data-line=\"\">wp-content\/uploads\/<\/code> directory.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Custom Code:<\/strong>\n<ul>\n<li>If the file contains custom code that is not theme or plugin-specific, you might consider creating a custom directory in the WordPress root directory (beside the wp-content folder).<\/li>\n<li>For example, you could create a folder named <code class=\"\" data-line=\"\">custom-code<\/code> and place your file there.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Child Theme:<\/strong>\n<ul>\n<li>If you are working with a child theme (which is recommended for making modifications to an existing theme), place the file in the child theme folder, not the parent theme folder.<\/li>\n<li>The child theme&#8217;s folder is typically located in <code class=\"\" data-line=\"\">wp-content\/themes\/child-theme\/<\/code>.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>Remember to always follow best practices and ensure that your file placement aligns with WordPress coding standards. If the file is part of a theme or plugin, modifications should be done through child themes or hooks to avoid losing changes during theme or plugin updates.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"mt-1 flex justify-start gap-3 empty:hidden\">\n<div class=\"text-gray-400 flex self-end lg:self-center justify-center lg:justify-start mt-0 -ml-1 visible\"><button class=\"flex items-center gap-1.5 rounded-md p-1 text-xs text-token-text-tertiary hover:text-token-text-primary md:invisible md:group-hover:visible md:group-[.final-completion]:visible\"><\/button><\/p>\n<div class=\"flex\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"w-full text-token-text-primary\" data-testid=\"conversation-turn-6\">\n<div class=\"px-4 py-2 justify-center text-base md:gap-6 m-auto\">\n<div class=\"flex flex-1 text-base mx-auto gap-3 md:px-5 lg:px-1 xl:px-5 md:max-w-3xl lg:max-w-[40rem] xl:max-w-[48rem] group\">\n<div class=\"flex-shrink-0 flex flex-col relative items-end\">\n<div>\n<div class=\"pt-0.5\">\n<div class=\"gizmo-shadow-stroke flex h-6 w-6 items-center justify-center overflow-hidden rounded-full\">\n<div class=\"relative flex\"><img loading=\"lazy\" decoding=\"async\" class=\"rounded-sm\" src=\"https:\/\/lh3.googleusercontent.com\/a\/AEdFTp5kCToIo5FGfvLjQcTlYkf3AuIVZw_8xqWtDU35Gw=s96-c\" alt=\"User\" width=\"24\" height=\"24\" data-nimg=\"1\" \/><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"relative flex w-full flex-col lg:w-[calc(100%-115px)]\">\n<div class=\"font-semibold select-none\">You<\/div>\n<div class=\"flex-col gap-1 md:gap-3\">\n<div class=\"flex flex-grow flex-col max-w-full\">\n<div class=\"min-h-[20px] text-message flex flex-col items-start gap-3 whitespace-pre-wrap break-words [.text-message+&amp;]:mt-5 overflow-x-auto\" data-message-author-role=\"user\" data-message-id=\"aaa2ada2-c5c5-4e58-8f5f-f82f432abd53\">\n<div class=\"\">how to load th files in custom-code<\/div>\n<\/div>\n<\/div>\n<div class=\"mt-1 flex justify-start gap-3 empty:hidden\">\n<div class=\"text-gray-400 flex self-end lg:self-center justify-center lg:justify-start mt-0 -ml-1 visible\">\n<div class=\"flex items-center gap-1.5 text-xs\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"w-full text-token-text-primary\" data-testid=\"conversation-turn-7\">\n<div class=\"px-4 py-2 justify-center text-base md:gap-6 m-auto\">\n<div class=\"flex flex-1 text-base mx-auto gap-3 md:px-5 lg:px-1 xl:px-5 md:max-w-3xl lg:max-w-[40rem] xl:max-w-[48rem] group\">\n<div class=\"flex-shrink-0 flex flex-col relative items-end\">\n<div>\n<div class=\"pt-0.5\">\n<div class=\"gizmo-shadow-stroke flex h-6 w-6 items-center justify-center overflow-hidden rounded-full\">\n<div class=\"relative p-1 rounded-sm h-9 w-9 text-white flex items-center justify-center\">ChatGPT<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"relative flex w-full flex-col lg:w-[calc(100%-115px)] agent-turn\">\n<div class=\"font-semibold select-none\">ChatGPT<\/div>\n<div class=\"flex-col gap-1 md:gap-3\">\n<div class=\"flex flex-grow flex-col max-w-full\">\n<div class=\"min-h-[20px] text-message flex flex-col items-start gap-3 whitespace-pre-wrap break-words [.text-message+&amp;]:mt-5 overflow-x-auto\" data-message-author-role=\"assistant\" data-message-id=\"6d82e83c-4ce0-4c3c-a12f-608708ca0e8d\">\n<div class=\"markdown prose w-full break-words dark:prose-invert light\">\n<p>To load files in custom code in WordPress, you typically use the <code class=\"\" data-line=\"\">wp_enqueue_script<\/code> and <code class=\"\" data-line=\"\">wp_enqueue_style<\/code> functions. These functions are used to include JavaScript and CSS files, respectively. Here&#8217;s a basic guide on how to load files in custom code:<\/p>\n<h3>Loading JavaScript Files:<\/h3>\n<ol>\n<li><strong>Create Your JavaScript File:<\/strong>\n<ul>\n<li>Create a new JavaScript file (e.g., <code class=\"\" data-line=\"\">custom-script.js<\/code>) and add your code.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Place the File in Your Custom Code Folder:<\/strong>\n<ul>\n<li>If you created a custom folder for your code (e.g., <code class=\"\" data-line=\"\">custom-code<\/code>), place the JavaScript file there.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Enqueue the Script in Your Theme&#8217;s <code class=\"\" data-line=\"\">functions.php<\/code> or Custom Code File:<\/strong>\n<ul>\n<li>Open your theme&#8217;s <code class=\"\" data-line=\"\">functions.php<\/code> file or your custom code file.<\/li>\n<li>Use the <code class=\"\" data-line=\"\">wp_enqueue_script<\/code> function to enqueue your script.<\/li>\n<\/ul>\n<div class=\"dark bg-black rounded-md\">\n<div class=\"flex items-center relative text-token-text-secondary bg-token-surface-primary px-4 py-2 text-xs font-sans justify-between rounded-t-md\">php<span class=\"\" data-state=\"closed\"><button class=\"flex gap-1 items-center\">Copy code<\/button><\/span><\/div>\n<div class=\"p-4 overflow-y-auto\"><code class=\"\" data-line=\"\">&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;\/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;enqueue_custom_script&lt;\/span&gt;() &lt;\/span&gt;{<br \/>\n    &lt;span class=&quot;hljs-comment&quot;&gt;\/\/ Enqueue the script&lt;\/span&gt;<br \/>\n    &lt;span class=&quot;hljs-title function_ invoke__&quot;&gt;wp_enqueue_script&lt;\/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&#039;custom-script&#039;&lt;\/span&gt;, &lt;span class=&quot;hljs-title function_ invoke__&quot;&gt;get_template_directory_uri&lt;\/span&gt;() . &lt;span class=&quot;hljs-string&quot;&gt;&#039;\/custom-code\/custom-script.js&#039;&lt;\/span&gt;, &lt;span class=&quot;hljs-keyword&quot;&gt;array&lt;\/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&#039;jquery&#039;&lt;\/span&gt;), &lt;span class=&quot;hljs-string&quot;&gt;&#039;1.0&#039;&lt;\/span&gt;, &lt;span class=&quot;hljs-literal&quot;&gt;true&lt;\/span&gt;);<br \/>\n}<\/p>\n<p>&lt;span class=&quot;hljs-comment&quot;&gt;\/\/ Hook the function to the &#039;wp_enqueue_scripts&#039; action&lt;\/span&gt;<br \/>\n&lt;span class=&quot;hljs-title function_ invoke__&quot;&gt;add_action&lt;\/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&#039;wp_enqueue_scripts&#039;&lt;\/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&#039;enqueue_custom_script&#039;&lt;\/span&gt;);<br \/>\n<\/code><\/div>\n<\/div>\n<ul>\n<li>Make sure to adjust the path to your custom JavaScript file accordingly.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3>Loading Stylesheet Files:<\/h3>\n<ol>\n<li><strong>Create Your Stylesheet File:<\/strong>\n<ul>\n<li>Create a new stylesheet (e.g., <code class=\"\" data-line=\"\">custom-style.css<\/code>) and add your styles.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Place the File in Your Custom Code Folder:<\/strong>\n<ul>\n<li>If you created a custom folder for your code (e.g., <code class=\"\" data-line=\"\">custom-code<\/code>), place the stylesheet file there.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Enqueue the Style in Your Theme&#8217;s <code class=\"\" data-line=\"\">functions.php<\/code> or Custom Code File:<\/strong>\n<ul>\n<li>Open your theme&#8217;s <code class=\"\" data-line=\"\">functions.php<\/code> file or your custom code file.<\/li>\n<li>Use the <code class=\"\" data-line=\"\">wp_enqueue_style<\/code> function to enqueue your stylesheet.<\/li>\n<\/ul>\n<div class=\"dark bg-black rounded-md\">\n<div class=\"flex items-center relative text-token-text-secondary bg-token-surface-primary px-4 py-2 text-xs font-sans justify-between rounded-t-md\">php<span class=\"\" data-state=\"closed\"><button class=\"flex gap-1 items-center\">Copy code<\/button><\/span><\/div>\n<div class=\"p-4 overflow-y-auto\"><code class=\"\" data-line=\"\">&lt;span class=&quot;hljs-function&quot;&gt;&lt;span class=&quot;hljs-keyword&quot;&gt;function&lt;\/span&gt; &lt;span class=&quot;hljs-title&quot;&gt;enqueue_custom_style&lt;\/span&gt;() &lt;\/span&gt;{<br \/>\n    &lt;span class=&quot;hljs-comment&quot;&gt;\/\/ Enqueue the stylesheet&lt;\/span&gt;<br \/>\n    &lt;span class=&quot;hljs-title function_ invoke__&quot;&gt;wp_enqueue_style&lt;\/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&#039;custom-style&#039;&lt;\/span&gt;, &lt;span class=&quot;hljs-title function_ invoke__&quot;&gt;get_template_directory_uri&lt;\/span&gt;() . &lt;span class=&quot;hljs-string&quot;&gt;&#039;\/custom-code\/custom-style.css&#039;&lt;\/span&gt;, &lt;span class=&quot;hljs-keyword&quot;&gt;array&lt;\/span&gt;(), &lt;span class=&quot;hljs-string&quot;&gt;&#039;1.0&#039;&lt;\/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&#039;all&#039;&lt;\/span&gt;);<br \/>\n}<\/p>\n<p>&lt;span class=&quot;hljs-comment&quot;&gt;\/\/ Hook the function to the &#039;wp_enqueue_scripts&#039; action&lt;\/span&gt;<br \/>\n&lt;span class=&quot;hljs-title function_ invoke__&quot;&gt;add_action&lt;\/span&gt;(&lt;span class=&quot;hljs-string&quot;&gt;&#039;wp_enqueue_scripts&#039;&lt;\/span&gt;, &lt;span class=&quot;hljs-string&quot;&gt;&#039;enqueue_custom_style&#039;&lt;\/span&gt;);<br \/>\n<\/code><\/div>\n<\/div>\n<ul>\n<li>Adjust the path to your custom stylesheet file accordingly.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3>Important Notes:<\/h3>\n<ul>\n<li>Enqueue scripts and styles using the appropriate hooks, such as <code class=\"\" data-line=\"\">wp_enqueue_scripts<\/code>.<\/li>\n<li>Use <code class=\"\" data-line=\"\">get_template_directory_uri()<\/code> to get the correct path to your theme directory.<\/li>\n<li>Adjust the dependencies, version number, and other parameters according to your requirements.<\/li>\n<\/ul>\n<p>Remember to clear any caching mechanisms you have in place, as caching might prevent changes from immediately reflecting on the website.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"mt-1 flex justify-start gap-3 empty:hidden\">\n<div class=\"text-gray-400 flex self-end lg:self-center justify-center lg:justify-start mt-0 -ml-1 visible\"><button class=\"flex items-center gap-1.5 rounded-md p-1 text-xs text-token-text-tertiary hover:text-token-text-primary md:invisible md:group-hover:visible md:group-[.final-completion]:visible\"><\/button><\/p>\n<div class=\"flex\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"w-full text-token-text-primary\" data-testid=\"conversation-turn-8\">\n<div class=\"px-4 py-2 justify-center text-base md:gap-6 m-auto\">\n<div class=\"flex flex-1 text-base mx-auto gap-3 md:px-5 lg:px-1 xl:px-5 md:max-w-3xl lg:max-w-[40rem] xl:max-w-[48rem] group\">\n<div class=\"flex-shrink-0 flex flex-col relative items-end\">\n<div>\n<div class=\"pt-0.5\">\n<div class=\"gizmo-shadow-stroke flex h-6 w-6 items-center justify-center overflow-hidden rounded-full\">\n<div class=\"relative flex\"><img loading=\"lazy\" decoding=\"async\" class=\"rounded-sm\" src=\"https:\/\/lh3.googleusercontent.com\/a\/AEdFTp5kCToIo5FGfvLjQcTlYkf3AuIVZw_8xqWtDU35Gw=s96-c\" alt=\"User\" width=\"24\" height=\"24\" data-nimg=\"1\" \/><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"relative flex w-full flex-col lg:w-[calc(100%-115px)]\">\n<div class=\"font-semibold select-none\">You<\/div>\n<div class=\"flex-col gap-1 md:gap-3\">\n<div class=\"flex flex-grow flex-col max-w-full\">\n<div class=\"min-h-[20px] text-message flex flex-col items-start gap-3 whitespace-pre-wrap break-words [.text-message+&amp;]:mt-5 overflow-x-auto\" data-message-author-role=\"user\" data-message-id=\"aaa2a7ef-a91b-468b-83fd-70540d0f89cd\">\n<div class=\"\">how to display files in custome-code<\/div>\n<\/div>\n<\/div>\n<div class=\"mt-1 flex justify-start gap-3 empty:hidden\">\n<div class=\"text-gray-400 flex self-end lg:self-center justify-center lg:justify-start mt-0 -ml-1 visible\">\n<div class=\"flex items-center gap-1.5 text-xs\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"w-full text-token-text-primary\" data-testid=\"conversation-turn-9\">\n<div class=\"px-4 py-2 justify-center text-base md:gap-6 m-auto\">\n<div class=\"flex flex-1 text-base mx-auto gap-3 md:px-5 lg:px-1 xl:px-5 md:max-w-3xl lg:max-w-[40rem] xl:max-w-[48rem] group final-completion\">\n<div class=\"flex-shrink-0 flex flex-col relative items-end\">\n<div>\n<div class=\"pt-0.5\">\n<div class=\"gizmo-shadow-stroke flex h-6 w-6 items-center justify-center overflow-hidden rounded-full\">\n<div class=\"relative p-1 rounded-sm h-9 w-9 text-white flex items-center justify-center\">ChatGPT<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"relative flex w-full flex-col lg:w-[calc(100%-115px)] agent-turn\">\n<div class=\"font-semibold select-none\">ChatGPT<\/div>\n<div class=\"flex-col gap-1 md:gap-3\">\n<div class=\"flex flex-grow flex-col max-w-full\">\n<div class=\"min-h-[20px] text-message flex flex-col items-start gap-3 whitespace-pre-wrap break-words [.text-message+&amp;]:mt-5 overflow-x-auto\" data-message-author-role=\"assistant\" data-message-id=\"ea6f1abf-3495-47fd-83fa-35135beed6c8\">\n<div class=\"markdown prose w-full break-words dark:prose-invert light\">\n<p>If by &#8221;display files in custom code&#8221; you mean including PHP files or executing code from specific files within your WordPress theme or custom code, you can use the <code class=\"\" data-line=\"\">include<\/code> or <code class=\"\" data-line=\"\">require<\/code> functions in your theme&#8217;s <code class=\"\" data-line=\"\">functions.php<\/code> file or other custom code files.<\/p>\n<p>Here&#8217;s a basic example:<\/p>\n<ol>\n<li><strong>Create Your Custom PHP File:<\/strong>\n<ul>\n<li>Create a new PHP file (e.g., <code class=\"\" data-line=\"\">custom-functions.php<\/code>) and add the PHP code you want to include or execute.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Place the File in Your Custom Code Folder:<\/strong>\n<ul>\n<li>If you have a custom folder for your code (e.g., <code class=\"\" data-line=\"\">custom-code<\/code>), place the PHP file there.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Include the File in Your Theme&#8217;s <code class=\"\" data-line=\"\">functions.php<\/code> or Custom Code File:<\/strong>\n<ul>\n<li>Open your theme&#8217;s <code class=\"\" data-line=\"\">functions.php<\/code> file or your custom code file.<\/li>\n<li>Use the <code class=\"\" data-line=\"\">include<\/code> or <code class=\"\" data-line=\"\">require<\/code> function to include your custom PHP file.<\/li>\n<\/ul>\n<div class=\"dark bg-black rounded-md\">\n<div class=\"flex items-center relative text-token-text-secondary bg-token-surface-primary px-4 py-2 text-xs font-sans justify-between rounded-t-md\">php<span class=\"\" data-state=\"closed\"><button class=\"flex gap-1 items-center\">Copy code<\/button><\/span><\/div>\n<div class=\"p-4 overflow-y-auto\"><code class=\"\" data-line=\"\">&lt;span class=&quot;hljs-comment&quot;&gt;\/\/ Include your custom PHP file&lt;\/span&gt;<br \/>\n&lt;span class=&quot;hljs-keyword&quot;&gt;include&lt;\/span&gt; &lt;span class=&quot;hljs-title function_ invoke__&quot;&gt;get_template_directory&lt;\/span&gt;() . &lt;span class=&quot;hljs-string&quot;&gt;&#039;\/custom-code\/custom-functions.php&#039;&lt;\/span&gt;;<br \/>\n&lt;span class=&quot;hljs-comment&quot;&gt;\/\/ or use require if you want the file to be mandatory for your theme to work:&lt;\/span&gt;<br \/>\n&lt;span class=&quot;hljs-comment&quot;&gt;\/\/ require get_template_directory() . &#039;\/custom-code\/custom-functions.php&#039;;&lt;\/span&gt;<br \/>\n<\/code><\/div>\n<\/div>\n<ul>\n<li>Adjust the path to your custom PHP file accordingly.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Use the Functions or Code from the Included File:<\/strong>\n<ul>\n<li>Now, you can use the functions or code defined in your included PHP file within your theme or other custom code.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3>Important Note:<\/h3>\n<ul>\n<li>Make sure to use proper error handling and validation to ensure that the included files exist and are accessible.<\/li>\n<li>Keep your code organized and well-documented for better maintenance.<\/li>\n<\/ul>\n<p>Remember that this method is suitable for organizing and structuring your code but should be used judiciously to maintain code clarity and avoid redundancy. If your custom code includes functionalities that are more complex or require classes and hooks, consider creating a custom WordPress plugin instead of directly adding code to the theme&#8217;s <code class=\"\" data-line=\"\">functions.php<\/code> file.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"mt-1 flex justify-start gap-3 empty:hidden\">\n<div class=\"text-gray-400 flex self-end lg:self-center justify-center lg:justify-start mt-0 -ml-1 visible\"><button class=\"flex items-center gap-1.5 rounded-md p-1 text-xs text-token-text-tertiary hover:text-token-text-primary md:invisible md:group-hover:visible md:group-[.final-completion]:visible\"><\/button><\/p>\n<div class=\"flex items-center gap-1.5 text-xs\"><\/div>\n<div class=\"flex\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"mx-auto\">\n<div data-projection-id=\"34\">\n<div class=\"mx-auto mt-2 inline-flex rounded-xl border border-gray-100 dark:border-gray-700\"><\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>how to make wordpress page display json ChatGPT ChatGPT If you want to display JSON data on a WordPress page, you can use a combination of custom code and plugins. Here&#8217;s a step-by-step guide: Create a WordPress Page: Log in to your WordPress admin dashboard. Navigate to &#8221;Pages&#8221; and create a new page or edit [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[138],"tags":[190],"class_list":["post-1729","post","type-post","status-publish","format-standard","hentry","category-wordpress","tag-custom-code"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/yellotab.se\/x056\/wp-json\/wp\/v2\/posts\/1729","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yellotab.se\/x056\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yellotab.se\/x056\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yellotab.se\/x056\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/yellotab.se\/x056\/wp-json\/wp\/v2\/comments?post=1729"}],"version-history":[{"count":1,"href":"https:\/\/yellotab.se\/x056\/wp-json\/wp\/v2\/posts\/1729\/revisions"}],"predecessor-version":[{"id":1730,"href":"https:\/\/yellotab.se\/x056\/wp-json\/wp\/v2\/posts\/1729\/revisions\/1730"}],"wp:attachment":[{"href":"https:\/\/yellotab.se\/x056\/wp-json\/wp\/v2\/media?parent=1729"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yellotab.se\/x056\/wp-json\/wp\/v2\/categories?post=1729"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yellotab.se\/x056\/wp-json\/wp\/v2\/tags?post=1729"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}