List all Posts
Outputs a single list of all your posts.
Thanks, Mickey! (Edited a bit for simplicity)
Outputs a single list of all your posts.
Thanks, Mickey! (Edited a bit for simplicity)
When you are locked out of your WordPress site and have no access to PHPMyAdmin, add this to your functions.php file to create a new admin user account.
Remove it from the functions file after you’re successfully logged in. (The user will remain.)
Thanks for the snippet, WPBeginner!
When creating custom post types, you often need custom fields for them. In the past, your options were “normal” or “side” with priorities. Depending on what else is displayed on your edit screen, these boxes could vary in where they appeared.
And sometimes you just need to add a comment or note to the edit pages.
Good News! We now have new hooks to place them precisely:
Here’s an article that explains the usage: https://make.wordpress.org/core/2012/12/01/more-hooks-on-the-edit-screen/
You have a .csv file with a date column that is formatted like this: 12/1/2015 (‘m/d/Y’).
You need to import it into a MySQL database DATE field named “my_dates”.
A straight import will result in all your dates showing up as ‘0000-00-00’, because MySQL uses the format ‘Y-m-d’, and won’t translate it natively.
Here’s the solution:
Create a VARCHAR field named “my_text_dates” in the database, and import the dates there.
Then, run this query:
Then, just delete the “my_text_dates” field, and you’re all set!
NOTE: the ‘%m/%d/%Y’ portion of the update statement needs to match exactly the format of your text date field.
Programmatically add an item to any menu that is called with wp_nav_menu.
Thanks, Micah Wood! https://gist.github.com/wpscholar/1249995
The easiest way to see what data is being used inside a script. Add this script to your page (or in functions.php for sitewide use).
Then call it inside your function like this:
Then just look at your console log to see the output.
Hint: if you are tracking one variable through a script and want to see how it changes, try something like this:
4.2 added the ability to use Emojicons in WP posts. If you don’t use them, you can remove the (unnecessary) scripts this adds to the header on all your site pages. Here’s the code for your functions.php file:
Thank you, Paulund!
http://www.paulund.co.uk/disable-emojicons-introduced-in-wordpress-4-2
This will output the name of the template being called on any particular page or post or archive.
Adding shortcodes to template files is a bit tricky. Although [ embed]myvideourl[ /embed] looks like a regular WP shortcode, it’s not handled the same way.
It works just as expected in a content block, but not so in a template file. Here’s the code to embed into the template:
NOTE: To use this code, you will need to remove the spaces inside the brackets before ’embed’ and ‘/embed’.