Wordpress
From Wasya Wiki
					
										
					
					Contents
Plugins
- wp-subtitle
 
Install
sudo apt-get install php5-mysqlnd-ms
Develop
Debug
define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', false ); @ini_set( 'display_errors', 0 );
// Use dev versions of core JS and CSS files (only needed if you are modifying these core files) define( 'SCRIPT_DEBUG', true );
List Categories
From: https://stackoverflow.com/questions/39704715/how-to-display-all-categories-in-wordpress/43927536
$args = array(
    'child_of'            => 0,
    'current_category'    => 0,
    'depth'               => 0,
    'echo'                => 1,
    'exclude'             => '',
    'exclude_tree'        => '',
    'feed'                => '',
    'feed_image'          => '',
    'feed_type'           => '',
    'hide_empty'          => 0,
    'hide_title_if_empty' => false,
    'hierarchical'        => true,
    'order'               => 'ASC',
    'orderby'             => 'name',
    'separator'           => '<br />',
    'show_count'          => 0,
    'show_option_all'     => '',
    'show_option_none'    => __( 'No categories' ),
    'style'               => 'list',
    'taxonomy'            => 'category',
    'title_li'            => __( 'Categories' ),
    'use_desc_for_title'  => 1,
);
var_dump( wp_list_categories($args) );
REPL
php -a
define('WP_USE_THEMES', false);
require('./wp-load.php');
$loop = get_posts( 'numberposts=1' );
$subtitle = new WP_Subtitle( 185 );
var_dump( $subtitle->get_raw_subtitle() );
Move Wordpress
update wp_options set option_value='http://staging.annesque.com' where option_id in (2, 1); cat 20180529_annesque_wp.sql | sed 's/utf8mb4_unicode_520_ci/utf8mb4_unicode_ci/' > out.sql chown www-data:www-data <the wp dir> apt-get install php5-mysqlnd-ms apt-get install libapache2-mod-php5
Get a json of a post
https://piousbox.com/wp-json/wp/v2/posts?slug=<slug>
Menus
      <h2 class='widget-title' ><?= wp_get_nav_menu_name('footer') ?></h2>
      <?php if ( has_nav_menu( 'footer' ) ) : ?>
        <nav aria-label="Secondary menu" class="footer-navigation" >
          <ul class="footer-navigation-wrapper">
            <? wp_nav_menu(array('theme_location' => 'footer' ) ); ?>
          </ul>
        </nav>
      <?php endif; ?>
Test
Install
bash bin/install-wp-tests.sh usage: bin/install-wp-tests.sh <db-name> <db-user> <db-pass> [db-host] [wp-version] [skip-database-creation]
Run
phpunit
Troubleshoot
Wordpress plugin install: Could not create directory
sudo chown -R www-data:www-data ../../wordpress_webdevzine/
Change password
UPDATE `wp_users` SET `user_pass` = MD5( 'new_password' ) WHERE `wp_users`.`user_login` = "admin_username";
wp-json/elementor/v1/globals 404 not found
Restarting a couple of times worked...
Going into settings->permalinks and re-saving the setting, worked.
Turn on logging
@ini_set( 'display_errors', getenv('display_errors') );
@ini_set( 'display_errors', 1 );
/var/www/html/wp-content/debug.log will have the file.