How to Wordpress: Personalization and Usage
Q&A to use Wordpress at its best and set it up as needed.
To show recently modified articles on the home page
By default, WordPress displays the most recently created items. But if you recently updated an article because the topic is returning to the news, you prefer that this article not be buried at the bottom of the site, but appear on the front page.
To do this, add the following line to the index.php file before the loop:
<?php query_posts($query_string . '&orderby=modified&order=desc'); ?>
And after the loop:
<?php wp_reset_query(); ?>
The full code becomes:
<?php query_posts($query_string . '&orderby=modified&order=desc'); ?>
<?php while ( have_posts() ) : the_post() ?> ... <?php endwhile ?> <?php wp_reset_query(); ?>
This also applies to mapping by category.
Show last modified date
Place this line inside the loop:
<p>Dernière modification: <?php the_modified_date(); ?></p>
You can specify the display format as a function parameter in the string. Read more in the Code.
How to: Create Readable URLs
The first step in installing WordPress is to configure it to create meaningful URLs.
"pretty" URLs are built from the name of the ticket and have the advantage of containing keywords that match its content, which is good for a link. To have meaningful URLs, go to the configuration, permalian, and enter the following handle:
/%postname%
You can include a category in the URL, but this has drawbacks. Click the information link on the setup page to view all options.
When creating tickets, it is better to create links without articles and apostrophes, even if the name is restored after creating a link.
How to bring a resume to the main
page?And also about research by category or others. This can be done with or without the plugin. The first paragraph is a summary of the post. We insert the code
<!--More-->
after this first paragraph (it may contain an image). In visual mode in the wysiwy editor with an icon representing the general page in half.
How not to save earlier versions
Starting with version 2.6, Wordpress saves a version of the article after each change, which usually makes no sense and in some cases can saturate your database! If you change the text to add a comma, you don't need text without a comma!
To cancel this behavior, add a flag to the wp-config.php file, the root of the CMS, immediately after installation:
define('WP_POST_REVISIONS',false);
How to erase edits
?The simplest solution would be this SQL query from phpMyAdmin:
DELETE FROM wp_posts WHERE post_type = "revision";
However, links are created between tickets and other tables, in particular for categories that also need to be erased. This request was offered by:
DELETE a,b,c FROM wp_posts a LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id) LEFT JOIN wp_postmeta c ON (a.ID = c.post_id) WHERE a.post_type = 'revision'
The suffix may be different from wp _ in the database (see wp_config.php ).
Back up the database with the command.
There is also a plugin if you don't want to touch SQL.
Delete AutoEnumeration
The way Wordpress manages usernames leaves the site vulnerable. Here's the code to avoid it:
RewriteEngine On RewriteCond %{REQUEST_URI} !/wp-admin.*
RewriteCond %{QUERY_STRING} ^author=.*$
RewriteRule (.*) /? [L,R=302] RewriteCond %{THE_REQUEST} wp.config.php [NC]
RewriteRule .* - [F,L]
Remove JavaScript from Emojis
It's like injecting code, but no, starting with version 4.2, this software itself adds this JavaScript block to the top of your pages without asking for your opinion!
This practically only serves content written in Kanji (Japanese) and it is not known why they decided to integrate it by default into Wordpress. This is not their first depth. To remove this block from JS, add two lines at the end of the functions.php file:
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
Use Google Docs as a text editor
Content made online using Google Docs can be published as pages of your Wordpress site/blog.
To do this, after compiling the page and closing the document...
- Look at the list of documents.
- Next to the page you want to publish, open the actions list and click Publish or Publish.
A new page will appear, offering to publish the document or publish it to a blog.
- Click Blog Entry (or Blog Post).
- Or, if your site is not already associated with Google Docs, click on the "setting" command.
You will receive the following form, which still needs to be completed ...
