Skip to content

Instantly share code, notes, and snippets.

View LeanSeverino1022's full-sized avatar

Leandro Severino LeanSeverino1022

View GitHub Profile
@LeanSeverino1022
LeanSeverino1022 / gulp.md
Last active April 15, 2020 13:45
Gulp 4 Cheatsheet #cheatsheet #vanillajs #gulp
@LeanSeverino1022
LeanSeverino1022 / notes.md
Last active April 6, 2020 19:05
learnings #marketing

Libraries and Frameworks may become obsolete, but the concepts and solutions they propose often survive the test of time

Stories that are GEMS

  • Don't be a perfectionist, commit to a curriculum
  • Networking and meetups, and more networking!
  • He shared the email he sent to potential clients. His email was good enough that a lot replied to his email and showed interest.
@LeanSeverino1022
LeanSeverino1022 / readme,md
Created April 6, 2020 17:41
Is your site good enough #marketing
You need to think like a site visitor and as the business owner (of the website)
1. Is the site fulfilling what I wanted?
2. Am I getting the answers I came here for?
3. Do I trust this business?
As the “owner” of the website, you need to be thinking: Is my website answering the questions and doubts my site visitor is thinking at this moment? What can I do to answer their questions? What can I do on my website to convince the site visitor to perform the action I’d like them to take?
@LeanSeverino1022
LeanSeverino1022 / readme.md
Last active April 6, 2020 12:10
[COLD EMAIL TIPS] #marketing
@LeanSeverino1022
LeanSeverino1022 / snipper.md
Last active April 5, 2020 13:00
[Custom Query Pagination] #wordpress

Example

The simple yet important lines are

'paged' => get_query_var('paged', 1), //1 is fallback if wp cannot find the page number dynamically
AND

'total' => $pastEvents->max_num_pages,
@LeanSeverino1022
LeanSeverino1022 / snippet.md
Created April 5, 2020 05:01
[Show today's date in WP] #wordpress

NOTE : Do not be mistaken! If you use the function get_the_date() from WP, it will display the date when the post/page/archive was created like it is explained here.

If you want to display the current date, use the date() method.

link: http://php.net/manual/en/function.date.php

<?php 
$today = date("F j, Y, g:i a");                 // March 10, 2001, 5:16 pm
@LeanSeverino1022
LeanSeverino1022 / snippet.md
Created April 5, 2020 04:31
[Create a new query to run inside your page or template.] #wordpress

All of the above examples showed you how to modify the main query. In many instances, you’ll want to run a separate query to load different information, and leave the main query unchanged. This is where Custom WordPress Queries are useful.

This is best when the content you’re displaying is being loaded in addition to your current page’s content. For instance, if you had a page about Spain and wanted to show your 5 most recent blog posts about Spain at the bottom, you could do something similar to this:

/**
 * Display posts about spain
 *
 */
function be_display_spain_posts() {
@LeanSeverino1022
LeanSeverino1022 / snippet.md
Created April 5, 2020 04:30
[Modify Query based on Post Meta] #wordpress

This example is a little more complex. We want to make some more changes to our Event post type. In addition to changing the posts_per_page, we want to only show upcoming or active events, and sort them by start date with the soonest first.

I’m storing Start Date and End Date in postmeta as UNIX timestamps. With UNIX timestamps, tomorrow will always be a larger number than today, so in our query we can simply make sure the end date is greater than right now.

Here’s more information on building Custom Metaboxes. My BE Events Calendar plugin is a good example of this query in practice.

If all the conditions are met, here’s the modifications we’ll do to the query:

Do a meta query to ensure the end date is greater than today Order by meta_value_num (the value of a meta field)

@LeanSeverino1022
LeanSeverino1022 / snippet.md
Created April 5, 2020 04:29
[Change Posts Per Page] #wordpress

Change Posts Per Page Let’s say you have a custom post type called Event. You’re displaying events in three columns, so instead of the default 10 posts per page you want 18. If you go to Settings > Reading and change the posts per page, it will affect your blog posts as well as your events.

We’ll use pre_get_posts to modify the posts_per_page only when the following conditions are met:

On the main query Not in the admin area (we only want this affecting the frontend display) On the events post type archive page

@LeanSeverino1022
LeanSeverino1022 / snippet.php
Last active April 5, 2020 04:18
[Exclude Category from Blog] #wordpress
/**
* Exclude Category from Blog
*
* @author Bill Erickson
* @link https://www.billerickson.net/customize-the-wordpress-query/
* @param object $query data
*
*/
function be_exclude_category_from_blog( $query ) {