WordPress FAQ

GENERAL

  • Need access to FTP issue.

    • Msg: ask for ftp credential

    • Ans:

This is user’s permission problem that will be solved by method given below that worked for me.

step-1 : First open wp-config.php file of your wordpress installation folder.
step-2: Copy below code and paste it at the end of the wp-config.php file.

define('FS_METHOD','direct');

step-3: Now open your droplet access console and enter root as username and its password.
step-4: Copy below code and paste it into access console where you have to specify your plugin directory path and then hit enter.

chmod 777 /yourwebsitename/public/wp-content/plugins/

Note: Replace your website name in the place of yourwebsitename.
Thank you.

  • ServerName not found 

    • Msg:

      • FQDN not found

      • mysqli connection exception, server name not found

    • Ans:

      • Rebuild wordpress after cleaning all old data on disk

  • Write parameter debug log 

$sudo vi ./your_wp_html/wp-includes/functions.php

---  functions.php ---
...
/**
* Simple helper to debug to the console
*
* @param $data object, array, string $data
* @param $context string  Optional a description.
*
* @return string
*/
function debug_to_console($data, $context = 'Debug in Console') {
    // Buffering to solve problems frameworks, like header() in this and not a solid return.
    ob_start();

    $output  = 'console.info(\'' . $context . ':\');';
    $output .= 'console.log(' . json_encode($data) . ');';
    $output  = sprintf('<script>%s</script>', $output);

    echo $output;
}
...
------


# Now Usage in any .php file


debug_to_console($xxx)


Result:

POSTS

  • Order posts by last modified/update date

$sudo vi {your_wp_html}/wp-content/themes/{your_current_theme}/functions.php

---  functions.php ---
...
# Remove `$query->is_main_query()` check if needs 
function lmt_orderby_modified_posts( $query ) {
    if( $query->is_main_query() && !is_admin() ) {
        if ( $query->is_home() || $query->is_category() || $query->is_tag() ) {
            $query->set( 'orderby', 'modified' );
            $query->set( 'order', 'desc' );
        }
    }
}
add_action( 'pre_get_posts', 'lmt_orderby_modified_posts' );
...
------

117 Comments

  1. plaquenil vs chloroquine It wasnt until about years later that he coined the term biopsychosocial model in his paper that came out in Science magazine and since then he has trained scores of health professionals in the biopsychosocial model and how to apply it to medical care. Pbnpgc

Leave a Reply

Your email address will not be published.


*