<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>WordPress Archives - SideCode</title>
	<atom:link href="https://sidecode.io/dev-blog-category/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>https://sidecode.io/dev-blog-category/wordpress/</link>
	<description>Web Development &#38; IT Consulting Company</description>
	<lastBuildDate>Thu, 14 May 2020 09:17:13 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.1</generator>

<image>
	<url>https://sidecode.io/wp-content/uploads/logo_icon-150x150.png</url>
	<title>WordPress Archives - SideCode</title>
	<link>https://sidecode.io/dev-blog-category/wordpress/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>WordPress &#8211; Change User Role Name</title>
		<link>https://sidecode.io/dev-blog/wordpress-change-user-role-name/</link>
		
		<dc:creator><![CDATA[jhonny]]></dc:creator>
		<pubDate>Mon, 05 Dec 2016 10:02:28 +0000</pubDate>
				<guid isPermaLink="false">https://sidecode.io/?post_type=blog&#038;p=1154</guid>

					<description><![CDATA[<p># WordPress &#8211; Change User Role name in functions.php : function change_role_name() { global $wp_roles; if ( ! isset( $wp_roles ) ) $wp_roles = new WP_Roles(); //You can list all currently available roles like this… // This is only for you to see whats going on, after checking, remove these 2 lines altogether $roles ...</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/wordpress-change-user-role-name/">WordPress &#8211; Change User Role Name</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h3><a href="“#”"># </a>WordPress &#8211; Change User Role name</h3>
<p>in functions.php :</p>
<pre>function change_role_name() {
    global $wp_roles;

    if ( ! isset( $wp_roles ) )
        $wp_roles = new WP_Roles();

    //You can list all currently available roles like this…
    // This is only for you to see whats going on, after checking, remove these 2 lines altogether 
    $roles = $wp_roles-&gt;get_names();
    print_r($roles);

    //You can replace "administrator" with any other role "editor", "author", "contributor" or "subscriber"...
    $wp_roles-&gt;roles['administrator']['name'] = 'god';
    $wp_roles-&gt;role_names['administrator'] = 'god';           
}
add_action('init', 'change_role_name');
</pre>
<p>That&#8217;s about it, all you need to do to change user role.</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/wordpress-change-user-role-name/">WordPress &#8211; Change User Role Name</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>WordPress &#8211; Creating a Child Theme, The Pure Basics</title>
		<link>https://sidecode.io/dev-blog/wordpress-creating-a-child-theme-the-pure-basics/</link>
		
		<dc:creator><![CDATA[jhonny]]></dc:creator>
		<pubDate>Mon, 14 Nov 2016 10:04:13 +0000</pubDate>
				<guid isPermaLink="false">https://sidecode.io/?post_type=blog&#038;p=1156</guid>

					<description><![CDATA[<p># WordPress &#8211; Creating a Child Theme, the pure basics A child theme consists of at least one directory (the child theme directory) that will be placed under the themes folder and two files (style.css and functions.php), which you will need to create: This is basically all you need to create a child theme. ...</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/wordpress-creating-a-child-theme-the-pure-basics/">WordPress &#8211; Creating a Child Theme, The Pure Basics</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h3><a href="#"># </a>WordPress &#8211; Creating a Child Theme, the pure basics</h3>
<p>A child theme consists of at least one directory (the child theme directory) that will be placed under the themes folder and two files (style.css and functions.php), which you will need to create:</p>
<p>This is basically all you need to create a child theme.</p>
<p>name the folder : themename-child<br />
style.css &#8211; header:</p>
<pre>/*
 Theme Name:   My Child
 Theme URI:    http://example.com/
 Description:  My Child Child Theme
 Author:       John Doe
 Author URI:   http://example.com
 Template:     myChild
 Version:      1.0.0
 Text Domain:  my-child-child
*/ 
</pre>
<p>functions.php:</p>
<pre> // Opening PHP tag - nothing should be before this, not even whitespace

add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );

}

</pre>
<p>Note: Check their is no trailing space after this close php tag (<code>?&gt;</code>).</p>
<p>Now the thumb rule is that if you want to override a file in the pedant theme all you need to do is to create it with the exact same name in your child theme, or create new files with new functionality to extend the parent theme.</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/wordpress-creating-a-child-theme-the-pure-basics/">WordPress &#8211; Creating a Child Theme, The Pure Basics</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>WordPress &#8211; Contact Form 7 &#8211; Dynamically  Change Fields</title>
		<link>https://sidecode.io/dev-blog/wordpress-contact-form-7-dynamically-change-fields/</link>
		
		<dc:creator><![CDATA[jhonny]]></dc:creator>
		<pubDate>Tue, 08 Nov 2016 10:03:43 +0000</pubDate>
				<guid isPermaLink="false">https://sidecode.io/?post_type=blog&#038;p=1155</guid>

					<description><![CDATA[<p># WordPress &#8211; Contact Form 7 &#8211; Dynamically change fields yes you can use a plugin “something cf7 dynamic fields”, but their is a better way, or at least let’s call it, my way. We can change the fields via JavaScript on document ready… First of all Give the field an id (in contact ...</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/wordpress-contact-form-7-dynamically-change-fields/">WordPress &#8211; Contact Form 7 &#8211; Dynamically  Change Fields</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h3><a href="“#”"># </a>WordPress &#8211; Contact Form 7 &#8211; Dynamically change fields</h3>
<p>yes you can use a plugin “something cf7 dynamic fields”, but their is a better way, or at least let’s call it, my way.<br />
We can change the fields via JavaScript on document ready…<br />
First of all Give the field an id (in contact form 7 creation ):</p>
<pre>[email* your-email-2 id:cf7-send-email-to placeholder “send to..”]
</pre>
<p>Then attach the data from wherever on your app to a data attribute on some element that make sense so you can retrieve this field via javascript (pass from php to javascript nicely).<br />
Than add this:</p>
<pre><!-- Handles the form fields -->&lt;script&gt;
    jQuery(document).ready(function($) {
        var vendorEmailField = $('#cf7-send-email-to'); // get the form field
        var vendorNameField  = $('#cf7-company-name'); // get the form field
        var usernameField    = $('#cf7-your-name'); // get the form field
        var userEmailField   = $('#cf7-your-email'); // get the form field

        var vendorName  = $('p.vendor-title').text(); // get vendor name.
        var vendorEmail = $('#opensupsendform').data('vendormail');
        var userName = $('#opensupsendform').data('username');
        var userEmail = $('#opensupsendform').data('useremail');

        vendorEmailField.css('display','none');
        vendorNameField.css('background','#eee');
        vendorNameField.val(vendorName);
        vendorEmailField.val(vendorEmail);

        usernameField.val(userName);
        userEmailField.val(userEmail);

        vendorNameField.attr('readonly', true);

        // jobNumber.css('color','#aaa');
        // jobTitle.val(jobTitleData);
        // jobTitle.attr('readonly', true);
        // jobTitle.css('color','#aaa');
        // $('.wpcf7-response-output').css( "display", "none" );
    }); 
&lt;/script&gt;</pre>
<p>this dynamically add data to the form on ready().<br />
<code>val = $(‘selector’).data(‘key’)</code> &#8211; retrieve a data attribute val<br />
<code>string = $(‘selectior’).text()</code> &#8211; retrieve a element text (within the tags).<br />
<code>$(‘selector’).val()</code> &#8211; replace their value of the element (on this case the data in the field).</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/wordpress-contact-form-7-dynamically-change-fields/">WordPress &#8211; Contact Form 7 &#8211; Dynamically  Change Fields</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Fast WordPress Debugging (Debug to console)</title>
		<link>https://sidecode.io/dev-blog/fast-wordpress-debugging-debug-to-console/</link>
		
		<dc:creator><![CDATA[jhonny]]></dc:creator>
		<pubDate>Wed, 02 Nov 2016 10:18:57 +0000</pubDate>
				<guid isPermaLink="false">https://sidecode.io/?post_type=blog&#038;p=1167</guid>

					<description><![CDATA[<p>A fast way to debug that I use to debug in WordPress, In fact I got used to it so much that I use it on any PHP environment or framework that i work on. The method is debugging php variables and arrays to the console (the browser console) and will print out at ...</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/fast-wordpress-debugging-debug-to-console/">Fast WordPress Debugging (Debug to console)</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>A fast way to debug that I use to debug in WordPress, In fact I got used to it so much that I use it on any PHP environment or framework that i work on. The method is debugging php variables and arrays to the console (the browser console) and will print out at runtime as the code is being executed in the browser the variable value.</p>
<p>Just a small method that in WordPress I just add it (always) to the <code>functions.php</code> file, and in other php frameworks, add it as a general global helper function.</p>
<h3><a href="#">#</a> The Method</h3>
<pre><code>
/**
 *  Send debug code to the Javascript console (PHP Console Debugging)
 */
function debug_to_console($data, $tag = 'JHONNY') {
  if(is_array($data) || is_object($data)) {
     echo("&lt;script&gt;console.log('" . $tag. ": " .json_encode($data)."');&lt;/script&gt;");
  } else {
     echo("&lt;script&gt;console.log('" . $tag. ": " .$data."');&lt;/script&gt;");
  }
}
</code></pre>
<p>When added to <code>functions.php</code> It allows me to call the function anywhere in my theme,<br />
The first argument <code>$data</code> &#8211; It&#8217;s the variable or array that I want to to see his state (the value).<br />
The second argument <code>$tag</code> &#8211; It&#8217;s an optional tag you can add, so as it is printed out in the console, you can identify it better.</p>
<h3><a href="#">#</a> On Small Projects</h3>
<p>On small projects mostly there is no need to add the second argument, so as it is above, it will alwyas just print <code>"JHONNY: "</code> before the variable, so I know that this is printed out from this function.<br />
So all you need to do is just give it the var you want to debug:</p>
<p><code>debug_to_console($tax_name)</code></p>
<p>It will look like this (In the browser console):</p>
<p><img decoding="async" loading="lazy" class="aligncenter wp-image-56 size-full mdl-shadow--4dp" src="http://sidecode.co.il/wp-content/uploads/debugSmallerProjects.jpg" alt="debugsmallerprojects" width="1004" height="333" /></p>
<h3><a href="#">#</a> On larger Projects</h3>
<p>On larger projects, usually, I add the second argument with the class name or tepmplate page it belongs to with the var name, something like:</p>
<p><code>debug_to_console($image_url,"footer.php - imageUrl")</code></p>
<p>It will look like this (In the browser console):</p>
<p><img decoding="async" loading="lazy" class="aligncenter wp-image-55 size-full mdl-shadow--4dp" src="http://sidecode.co.il/wp-content/uploads/debuglargerProject.jpg" alt="debuglargerproject" width="1000" height="336" /></p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/fast-wordpress-debugging-debug-to-console/">Fast WordPress Debugging (Debug to console)</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>WordPress &#8211; Get a List of All User Roles (Existing on the Site)</title>
		<link>https://sidecode.io/dev-blog/wordpress-get-a-list-of-all-user-roles-existing-on-the-site/</link>
		
		<dc:creator><![CDATA[jhonny]]></dc:creator>
		<pubDate>Tue, 01 Nov 2016 10:00:58 +0000</pubDate>
				<guid isPermaLink="false">https://sidecode.io/?post_type=blog&#038;p=1149</guid>

					<description><![CDATA[<p># WordPress &#8211; Get a list of all user roles (existing in the site) sometimes you need to see all of the user roles in your website, to do that Add this in functions.php: function get_editable_roles() { global $wp_roles; $all_roles = $wp_roles-&#62;roles; $editable_roles = apply_filters('editable_roles', $all_roles); return $editable_roles; } Now, on some page of ...</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/wordpress-get-a-list-of-all-user-roles-existing-on-the-site/">WordPress &#8211; Get a List of All User Roles (Existing on the Site)</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h3><a href="“#”"># </a> WordPress &#8211; Get a list of all user roles (existing in the site)</h3>
<p>sometimes you need to see all of the user roles in your website, to do that Add this in functions.php:</p>
<pre>function get_editable_roles() {
    global $wp_roles;
    $all_roles = $wp_roles-&gt;roles;
    $editable_roles = apply_filters('editable_roles', $all_roles);
    return $editable_roles;
}
</pre>
<p>Now, on some page of site (page-template, front-page, something, add:</p>
<p><img decoding="async" loading="lazy" class="alignnone size-full wp-image-111" src="http://sidecode.co.il/wp-content/uploads/Screen-Shot-2016-11-08-at-17.07.41.png" alt="screen-shot-2016-11-08-at-17-07-41" width="1476" height="764" /></p>
<p>Now you have a list on the page of all the user roles and capabilities.<br />
Note: Totally remove this on a production website, I would also remove the function altogether to avoid mistakes, and leaving this on by accident.</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/wordpress-get-a-list-of-all-user-roles-existing-on-the-site/">WordPress &#8211; Get a List of All User Roles (Existing on the Site)</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>WP Query Show Post Count when Paginating results</title>
		<link>https://sidecode.io/dev-blog/wp-query-show-post-count-when-paginating-results/</link>
		
		<dc:creator><![CDATA[jhonny]]></dc:creator>
		<pubDate>Sat, 03 Sep 2016 10:02:10 +0000</pubDate>
				<guid isPermaLink="false">https://sidecode.io/?post_type=blog&#038;p=1153</guid>

					<description><![CDATA[<p># WP Query Show Post Count when Paginating results Let’s say that you doing a custom query, and their is pagination in place, and you want to show : “Displaying 2 out of 5 results” (2 results on this page, and you have 5 total in all of the pages). The way to do ...</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/wp-query-show-post-count-when-paginating-results/">WP Query Show Post Count when Paginating results</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h3><a href="“#”"># </a> WP Query Show Post Count when Paginating results</h3>
<p>Let’s say that you doing a custom query, and their is pagination in place, and you want to show :<br />
“Displaying 2 out of 5 results” (2 results on this page, and you have 5 total in all of the pages).</p>
<p>The way to do get the post count and present it nicely is:</p>
<pre>    $custom_query = new WP_Query( $custom_args ); 
     if ( $custom_query-&gt;have_posts() ) {
         echo “displaying : $custom_query-&gt;post_count()";  // how many on this page
         echo “out of total of: $custom_query-&gt;found_posts";  // how many total found
    }
</pre>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/wp-query-show-post-count-when-paginating-results/">WP Query Show Post Count when Paginating results</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>WordPress &#8211; Create a Custom User Role (and Delete a Role)</title>
		<link>https://sidecode.io/dev-blog/wordpress-create-a-custom-user-role-and-delete-a-role/</link>
		
		<dc:creator><![CDATA[jhonny]]></dc:creator>
		<pubDate>Thu, 14 Jul 2016 10:01:48 +0000</pubDate>
				<guid isPermaLink="false">https://sidecode.io/?post_type=blog&#038;p=1150</guid>

					<description><![CDATA[<p># WordPress &#8211; Create a custom user role Sometimes you want to create a special user with a special name and behavior inside WordPress The way to add a custom user role is the following: function add_capability() { // Add a custom user role (1) - Let’s say… God! $result = add_role( 'god', __(‘God'), ...</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/wordpress-create-a-custom-user-role-and-delete-a-role/">WordPress &#8211; Create a Custom User Role (and Delete a Role)</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h3><a href="“#”"># </a> WordPress &#8211; Create a custom user role</h3>
<p>Sometimes you want to create a special user with a special name and behavior inside WordPress<br />
The way to add a custom user role is the following:</p>
<pre>function add_capability() {
    // Add a custom user role (1) - Let’s say… God!
    $result = add_role( 'god', __(‘God'),
    array(
    'read' =&gt; true, // true allows this capability (because it’s god).
    'edit_posts' =&gt; true, // Allows user to edit their own posts
    'edit_pages' =&gt; true, // Allows user to edit pages
    'edit_others_posts' =&gt; true, // Allows user to edit others posts not just their own
    'create_posts' =&gt; true, // Allows user to create new posts
    'manage_categories' =&gt; true, // Allows user to manage post categories
    'publish_posts' =&gt; true, // Allows the user to publish, otherwise posts stays in draft mode
    'edit_themes' =&gt; false, // false denies this capability. User can’t edit your theme (god or no god, no on is touching my theme)
    'install_plugins' =&gt; false, // User cant add new plugins
    'update_plugin' =&gt; false, // User can’t update any plugins
    'update_core' =&gt; false // user cant perform core updates
     
    )
     
    );
</pre>
<pre>    // Add a custom user role (2) - member
     
    $result2 = add_role( 'member', __('Member' ),
     
    array(
    
   'read' =&gt; true, 
   'edit_posts' =&gt; true,
   'edit_pages' =&gt; true, 
   'edit_others_posts' =&gt; true, 
   'create_posts' =&gt; true,
   'manage_categories' =&gt; true, 
   'publish_posts' =&gt; true,
    'edit_themes' =&gt; false,
    'install_plugins' =&gt; false,
    'update_plugin' =&gt; false, 
   'update_core' =&gt; false
    )
    );
}

add_action( 'admin_init', ‘add_capability');
</pre>
<h3><a href="“#”"># </a> WordPress &#8211; Delete a user role</h3>
<p>You can also remove roles,<br />
To delete a user role, you should add in your function.php :</p>
<pre>remove_role( 'member' ); 
</pre>
<p>Note: Be carful cant be undone, also the users with this role will be with no privileges on the website,<br />
this will totally delete the role. and if you need to get it back, you need to add it all over again and set this role privileges all over again.</p>
<p>The post <a rel="nofollow" href="https://sidecode.io/dev-blog/wordpress-create-a-custom-user-role-and-delete-a-role/">WordPress &#8211; Create a Custom User Role (and Delete a Role)</a> appeared first on <a rel="nofollow" href="https://sidecode.io">SideCode</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/

Object Caching 0/204 objects using disk
Page Caching using disk: enhanced 
Database Caching 5/85 queries in 0.198 seconds using disk

Served from: sidecode.io @ 2026-05-13 20:37:41 by W3 Total Cache
-->