Create your own SEO plugin

<? Php

/ **

* @package Plugin_SEO

* @version 1.0

* /

/ *

Plugin Name: My SEO plugin

Plugin URI : https://ayudawp.com/

Description: Add meta boxes to include "description" and "title" goals for Open Graph and search engines.

Author: Fernando Tellado

Version: 1.0

Author URI: http://tellado.es

* /

function tes_mb_create () {

[19659021] / **

* @array $ screens Screen in which the meta box will be displayed

* @values ​​post, page, dashboard, link, attachment, custom_post_type

* /

$ screens = array ( 'post' 'page' ) ;

foreach ( $ screens as $ screen ) {[19659014] add_meta_box (

'tes-meta'

'SEO Settings helpWP' [19659014]

'tes_mb_function'

$ screen

'normal'

'high'

) ;

}

}

add_action ( 'add_meta_boxes' 'tes_mb_create' ) ;

function tes_mb_function ( $ post ) {

/ / if exist is [19659044] recover the values ​​ from the metadata

$ tes_meta_title = get_post_meta (] $ post -> ID '_ tes_meta_title' true ) ;

] $ tes_meta_description = get_post_meta ( $ post -> ID '_ tes_meta_description ' true ) ;

// A nonce field is added to test it later when we validate

wp_nonce_field ( 'tes_inner_custo m_box ' ' tes_inner_custom_box_nonce ' ) ;

echo '

'

Label "title":

<input style = "padding: 6px 4px; width: 300px "type =" text "name =" tes_meta_title "value =" ' . esc_attr ( $ tes_meta_title )

. '"/>

Meta" description ": ' . esc_attr ( $ tes_meta_description ) . '

' ;

}

[19659015] function tes_mb_save_data ( $ post_id ) {

/ *

* We have to verify that this provie ne of our screen and with the appropriate authorization,

* to launch save_post at any other time.

* /

// We check if the nonce has been defined.

if ( ! isset ( $ _ POST [ 'tes_inner_custom_box_nonce' ] ) )

return $ post_id ;

$ nonce = $ _ POST [ 'tes_inner_custom_box_nonce' ] ; 19659014] // Verify that the nonce is valid.

if ( ! wp_verify_nonce ( $ nonce 'tes_inner_custom_box' ) )

return $ post_id ;

// If it is a self-safeguard, our form will not be sent, as we do not want to do anything yet.

if ( defined ( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE [19659017])

return $ post_id ;

// We check user permissions.

if ( 'page' == $ _ POST [ 'post_type' ] ) {

if ( ! current_user_can ( 'edit_page' $ post_id ) )

return $ post_id ]

} else {

if ] ( ! current_user_can ( 'edit_post' $ post_id ) ] )

return $ post_id ;

}

/ * Ok, it's safe to keep the data. * /

// If there are old entries, we retrieve them

$ old_title = get_post_meta ( ] $ post_id '_ tes_meta_title' true ) ;

$ old_description = get_post_meta ( $ post_id '_ tes_meta_description' true ) ;

// We clean what the user entered.

$ title = sanitize_text_field ( $ _ POST [ 'tes_meta_title' ] [19659017]) ;

$ description = sanitize_text_field ( $ _ POST [ 'tes_meta_description' ] ) ;

// We update the meta field in the database.

update_post_meta ( $ post_id '_ tes_meta_title' $ title ] $ old_title ) ;

update_post_meta ( $ post_id ] '_ tes_meta_description' $ description $ old_description ) ];

}

add_action ( 'save_post' 'tes_mb_save_data' ) ;

function tes_mb_display () {

global $ post ;

// recupe We have the values ​​of the metadata if they exist

$ tes_meta_title = get_post_meta ( $ post -> ID '_ tes_meta_title' true ) ;

$ tes_meta_description = ] get_post_meta ( $ post -> ID '_ tes_meta_description' true ) ;

echo '

<meta property = "og: title" content = "' . $ tes_meta_title . '"/>

<meta property =" og: description "content =" ' . $ tes_meta_description . '"/>

<meta name =" description "content ="' . [19659026] $ tes_meta_description . '"/>

' ;

}

] add_action ( 'wp_head' 'tes_mb_display' ) ;

?>

How to make lists in HTML with WordPress

 learn html

If you regularly use the visual editor of WordPress you already know that you can create lists of elements of two types, numbered and bulleted, or in other words, ordered and unordered, but these are not the only possibilities.

If you value it and you go to the Text tab, or HTML, of the WordPress editor you can create more lists so let's review both those offered by the editor and others that you can use:

:: Ordered lists ::

The most common lists would be the numbered ones, which are created like this:

  1. ] First element
  2. Second element

And you get this:

  1. First element
  2. Second element

:: Disordered lists ::

The others offered by the WordPress editor are the bullet lists, which are made like this:

  • One item
  • Other items ento

And what you get is something like this:

:: Ordered lists that start with a specific number:

If you want to customize a sorted list so that, instead of starting with the number 1 , start with a number of your choice it will be done like this:

  1. Element that starts with number 5
  2. Next item

And you get this:

  1. Element that starts with number 5
  2. Next element

:: Ordered lists in Roman numerals ::

Another variation of ordered lists is to use Roman numerals instead of the usual ones, and it is done as follows:

  1. Element I
  2. Element II
  3. Element III
  4. Element IV

:: Lists ordered in letters ::

And we end with ordered lists but they use letters instead of numbers, very practical, and they are like this: [19659032] Element A

  • Element B
  • Element C
  • Element D
  • So I already have a few HTML tags more than you can add to your WordPress editor arsenal.

    WARNING : this post is two years or more ago. If it's a code or a plugin it might not work in the latest versions of WordPress, and if it's a news story it might be obsolete. Then do not say we have not warned you.

    Loading …

    That may also help you:

    Name of the entry in the "title" without using plugins

     rewrite html

    Yesterday, in the comments on the issue of the WordPress SEO by Yoast flaws came up a parallel debate, relative to if you really need SEO plugins for WordPress .

    Well, one of the most appreciated features of the SEO plugins is the writing of " titles ", so that if the theme is not prepared to do so, the plugin will take care of adding – in addition to the title of the site – the title of the entry in the tag " title ", the most important of any page.
     rewrite titles wordpress

    If it is necessary it is because, by default, WordPress does not do it, because it is the functioning of the function " wp_title ", and as long as they do not change it (hopefully), it's time to choose a theme that will Add this functionality, add it to the topic or use a plugin to do it.

    Or we can also do it using a simple function that does the same without modifying WordPress nor the theme that let's use, or have to install an SEO plugin .

    We just have to add the following code to your functions plugin:

    You save and you already have it, without plugins or anything.

    NOTICE : This publication is from two years ago or more. If it's a code or a plugin it might not work in the latest versions of WordPress, and if it's a news story it might be obsolete. Then do not say we have not warned you.

    Loading …

    That may also help you:

    Tag drop-down list

    I do not even remember the time that a reader, bored of the clouds of tags asked me how to make a drop-down list of labels not of categories which is what It is always more easily available. And the truth is that I wrote it down but until today I have not remembered to locate something to give it a solution.

    And instead of a solution I bring two. Better right?

    This nice code, which I found in WPlover will create a drop-down list of the labels, you decide where you want to show it, in the sidebar, at the end of each entry, yourself :

    <li id = "categories" >

    <? Php _e ( 'Entries in each tag' ) ; ?>

    <form action = [19659000] " <? php bloginfo ( 'url' ) ; ?> /" method = "get" >

    <? php

    $ select = wp_dropdown_categories ( 'taxonomy = post_tag & show_option_none = Select tag & show_count = 1 & orderby = name & echo = 0' ) ;

    $ select = preg_replace ( "# ] *)> # " "" $ select ) ;

    echo $ select ;

    ?>

    <entry type = "submit" ] value = "View" />

    The best of this code is that as it treats the tags as what they are, one more taxonomy, you can use it to do a drop down of your own taxonomies by changing taxonomy = post_tag by yours.

    if you want to make it even easier you also have a plugin that comes to be the ideal substitute for the previous code. Taxonomy dropdown widget once installed and active, add a widget to configure it to your liking and, if you prefer to show the result elsewhere you can use the function taxonomy_dropdown_widget as follows:

    Limit the number of labels to display in the theme • WordPress Help

    If you do not change the default options, when WordPress calls the function the_tags will show in your theme, where this call is, all the tags (tags) that you have marked for the entry in question. [19659002] And this creates a problem, when the same theme design does not show them well, especially if you usually mark many labels.

    In this case, what we have to do is limit by a function the number of labels to show, regardless of what you dial for the entry.

    To do this we will perform a little trick the_tags by adding some code to our function plugin this:

    // Limit tags displayed to 5

    add_filter ( 'term_links-post_tag' 'limit_tags' ) ;

    function limit_tags ( $ terms ) {

    return ] array_slice ( $ terms 0 5 true ) ;

    }

    The value to modify to your liking of this code is that of line 4, putting the terms to the number to which you want to limit the display of labels of the entry.

    Now you just have to make sure that your theme shows the native WordPress function of " impression " of the labels this:

    The question you're going to ask me … which one do you take? ?, then in this case the first 5 that you mark.

    How to change the WordPress emoticons (part 2) • WordPress Help

    Yesterday I discovered that since the last update I had lost my personalized smilies, to match my theme. Searching for here only appeared this other entry so to work …

    For the one that interests you that whenever WordPress is updated you do not lose your personal smilies I leave my solution

    First I create a folder "smilies " in the folder wp-content because this last folder does not suffer any updates.

    In the file of the theme / wp-content / themes / THEMENAME / functions.php I create a function for the entries and another one for the comments.

    function mis_smilies ( $ text ) {

    $ text = convert_smilies ( convert_smilies ( $ text ) ) ]

    $ text = str_replace ( 'wp-includes / images / smilies / icon _' [19659026] 'wp-content / smilies / icon _' $ text ) ;

    return $ text ;

    }

    add_filter ( 'comment_text' [19659026] 'mis_smilies' ) ;

    The main function would be str_replace () which will change the original URL (wp-includes / im ages / smilies /) for the folder in my smilies (wp-content / smilies /). In the entries, he only does that. In the comments I first have to convert the smilies codes into images and that's what WordPress does with the function convert_smilies () as I failed the code 8 ) I repeat the conversion and then change the folder

    With these functions we could have different smilies for each theme (editing its functions.php file) and / or be different from the entries and the comments (changing the folder).

    List of posts without page template

    If you want to show a list of posts published in a post or page you do not need to create a special template to show them but there is a simpler, looser solution for all types of user profiles. [19659002] This solution goes through a plugin (yes, do not jump on my delicate neck), but it does its job very well and gives you a lot of control over what will be displayed and how it will be done.
    [19659002] If you take advantage of the possibilities of the template tag get posts you have many options, and if you create special CSS classes you will have some very nice summaries.

    23 essential WordPress chops • WordPress Help

    If you are one of those who like to have cheat sheets, even printed, with which to have an arsenal of codes and WordPress tags, this list created by Graphic and Web Design Blog you will love it , and as some of it had already been translated I have replaced the links with the ones existing in Spanish, take note:

    Related posts without plugin • WordPress Help

    If you are one of those who like to remove plugins to use functions already available in WordPress this is a great hack that can offer you the functionality of related posts without using plugins like Related Posts or others.

    You just have to add the following code to the part of the ' loop ' in which you want the related posts to be displayed (usually in single.php or index.php ):

    1

    2

    3

    4

    5 [19659002] 6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    16

    17

    18

    19

    20

    21

    <? Php

    // to put in the loop, it shows 5 post titles related to the first tag of the current post ]

    $ tags = wp_get_post_tags ( $ post -> ID ) ;

    if ( $ tags ) {

    echo 'Post related ';

    $ first_tag = $ tags [ 0 ] -> term_id ;

    $ args = array (

    'tag__in' = > ] array ( $ first_tag )

    'post__not_in' = > ] array ( $ post -> ID )

    'showposts' [19659032] = > 5

    'caller_get_posts' = > 1

    ) ;

    $ my_query = new WP_Query ( $ args ) ] [19659000] if ( $ my_query -> have_posts () [1 9459027] ) {

    while ( $ my_query ->

    ) ) ) : : $ my_query -> the_post () ;

    ?> to href ; ] = " <? Php the_permalink () ?> " rel = "bookmark" title = "Permalink to <? php the_title_attribute () ; ? > "> <? Php the_title () ; ?> < / to ]> < / [19659108] p >

    <? Php

    endwhile ;

    ]}

    }

    ?>