Categories
WordPress WordPress Development

$post Object Output in WordPress

WP_Post Object

WP_Post Object
 (
 [ID] =>
 [post_author] =>
 [post_date] =>
 [post_date_gmt] =>
 [post_content] =>
 [post_title] =>
 [post_excerpt] =>
 [post_status] =>
 [comment_status] =>
 [ping_status] =>
 [post_password] =>
 [post_name] =>
 [to_ping] =>
 [pinged] =>
 [post_modified] =>
 [post_modified_gmt] =>
 [post_content_filtered] =>
 [post_parent] =>
 [guid] =>
 [menu_order] =>
 [post_type] =>
 [post_mime_type] =>
 [comment_count] =>
 [filter] =>
 )

Categories
WordPress WordPress Development

JSON Vs Array in a Database

JSON

  • Faster to encode JSON
  • Takes Less space
  • Human Readable
  • JSON can be used by many other languages

Terms Used : encode, decode

Array

  • Faster to unserialise Array

Terms Used : Serialise, Unserialise

Categories
WordPress WordPress Development

GitIgnore Directory

.gitignore Directory

Example Directory name : uploads

Ignoring ALL folders and files

 # .gitignore
uploads

Result:

# Will Ignore

/uploads # directory
/uploads # file
/example/path/uploads # directory
/example/path/uploads # file

Ignoring only the Root Directory

The correct syntax for that is to put leading and trailing slash:

 # .gitignore
/uploads/

Result:

 # will ignore
/uploads # directory

# will NOT ignore
/uploads              # file
/some/path/uploads    # directory
/another/path/uploads # file

Ignoring only the Root Directory and the Root File

 # .gitignore
/uploads

Result:

# will ignore

/uploads # directory
/uploads # file

Ignoring only Folders and not Files

# .gitignore
uploads/

Result:

# will ignore:
/uploads # directory
/some/path/uploads # directory

# will NOT ignore:
/another/path/uploads # file

Categories
WordPress WordPress Development

This exceeds GitHub’s file size limit of 100MB

Solution for “This exceeds GitHub’s file size limit of 100 MB” issue

git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch YOUR-FILE'
git push

Categories
WordPress WordPress Development

WP_Query Get Posts Published in the last 24 hours

$args = array(
 'post_type' => 'post',
 'posts_per_page' => '10',
 'date_query' => array(
 array(
 'after' => '24 hours ago'
 )
 )
 );
$the_posts = new WP_Query( $args );