• Resolved Yworld

    (@yworld)


    Hi,Thomas!
    It has turned out awry, but works ??
    screenshot:
    https://image.prntscr.com/image/0c184c86c90a4fdb8d77851d2c7d578a.png
    https://image.prntscr.com/image/324ad9a63a1a4fb18bfa8fc0b9436fdd.png

    In file add forum.php

    add_action("wp_head", array($this, 'wp_head_meta_description'), 1);
    add_action("wp_head", array($this, 'wp_head_meta_canonical'), 1);
    function wp_head_meta_description() {
    	
    	 if ($this->current_thread) {
    		echo '<meta name="description" content="'.esc_html($this->cut_string(stripslashes($this->get_name($this->current_thread, $this->table_threads)), 160)).'" />';
    	} else{
    		echo '<meta name="description" content="'.get_bloginfo('description').'" />';
    	}
    }
        function wp_head_meta_canonical() {
    		
    	 if ($this->current_thread) {
    		$str='<link rel="canonical" href="'.$this->get_link($this->current_thread, $this->links->topic, ($this->current_page + 1)).'" />';
    		$lit = "#038;";
    		$str = str_replace($lit, "", $str);
            echo $str;
    	} else{
    		echo '<!-- wp_head_meta_canonical -->';
    	}
    }

    You can replace?
    name=”description” content=”From of the first post” />

    rel=”canonical” href=”There is a variant easier to specify the link?” />

    @asgaros thanks for a wonderful plugin!

    • This topic was modified 8 years, 3 months ago by Yworld.
Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Asgaros

    (@asgaros)

    Hi @yworld

    Thank you, I didnt saw this. ??

    I will have a look into it and when it is working fine after testing I will implement it in the upcoming update.

    Thanks again! ??

    Thread Starter Yworld

    (@yworld)

    Magnificently, I’ll wait!

    Minor changes:

    function wp_head_meta_description() {
    	
    	 if ($this->current_thread) {
    		 $name = ($this->cut_string(stripslashes($this->get_name($this->current_thread, $this->table_threads)), 160));
    		 echo '<meta name="description" content="'.esc_html($name).'" />';
    	} else{
    		echo '<meta name="description" content=" '.__('Forum', 'asgaros-forum').' | '.get_bloginfo('description').'" />';
    	}
    }
        function wp_head_meta_canonical() {
    		
    		if ($this->current_thread) {
                $link = $this->get_link($this->current_thread, $this->links->topic, ($this->current_page + 1));
                $lit = "#038;";
    	    $link = str_replace($lit, "", $link);
                echo '<link rel="canonical" href="'.$link.'" />';
            } else{
    		    echo '<!-- wp_head_meta_canonical -->';
    	}
    }
    • This reply was modified 8 years, 3 months ago by Yworld.
    Thread Starter Yworld

    (@yworld)

    Added a line wrapping .PHP_EOL
    Comment out a line:
    // echo '<meta name="description" content=" '.__('Forum', 'asgaros-forum').' | '.get_bloginfo('description').'" />'.PHP_EOL;

    Add:
    echo '<!-- wp_head_meta_description -->'.PHP_EOL;
    Appears across its entire site

    Minor changes ?? :

    function wp_head_meta_description() {
    	
    	 if ($this->current_thread) {
    		 $name = ($this->cut_string(stripslashes($this->get_name($this->current_thread, $this->table_threads)), 160));
    		 echo '<meta name="description" content="'.esc_html($name).'" />'.PHP_EOL;
    	} else{
    	//	echo '<meta name="description" content=" '.__('Forum', 'asgaros-forum').' | '.get_bloginfo('description').'" />'.PHP_EOL;
    		echo '<!-- wp_head_meta_description -->'.PHP_EOL;
    	}
    }
        function wp_head_meta_canonical() {
    		
    		if ($this->current_thread) {
                $link = $this->get_link($this->current_thread, $this->links->topic, ($this->current_page + 1));
                $lit = "#038;";
    	    $link = str_replace($lit, "", $link);
                echo '<link rel="canonical" href="'.$link.'" />'.PHP_EOL;
            } else{
    		    echo '<!-- wp_head_meta_canonical -->'.PHP_EOL;
    	}
    }
    • This reply was modified 8 years, 3 months ago by Yworld.
    Plugin Author Asgaros

    (@asgaros)

    Am I right that we still have the problem with the code that those meta-tags are in the header multiple times if they got already created by the theme or other plugins? ??

    Thread Starter Yworld

    (@yworld)

    Elsewhere will display comments:
    <!– wp_head_meta_description –>
    <!– wp_head_meta_canonical –>

    Not scary. Meta tags only on the forum, No doubles on the site.

    • This reply was modified 8 years, 3 months ago by Yworld.
    • This reply was modified 8 years, 3 months ago by Yworld.
    Plugin Author Asgaros

    (@asgaros)

    Yes, for other pages it is fine. I just wonder if it has any impact at all when at the forum-page the description/canonical tags are multiple times and maybe just the first one is used by search engines.

    Thread Starter Yworld

    (@yworld)

    One time the tags on forum.
    According to the standard twice is impossible, Bots from difficult to understand. SEO will worsen.

    Plugin Author Asgaros

    (@asgaros)

    So you are using a WordPress theme which is not generating the description-meta. But at least the description-meta will be there twice when a user is using a theme which has something like this in the header.php file:

    <meta name="description" content="<?php bloginfo('description'); ?>" />

    Thread Starter Yworld

    (@yworld)

    I checked.

    1.Disabled All In One SEO Pack
    2.I activate the theme Twenty Twelve, in the code:
    <meta name=”description” content=”<?php bloginfo(‘description’); ?>” />
    https://image.prntscr.com/image/c4343d38b489425686327df5705524ab.png

    Verification: Home
    https://image.prntscr.com/image/a58ed3fc85e84fe58aed5ac3cff9b243.png
    Verification: ad plugin
    https://image.prntscr.com/image/a5cf2f638d894600897339aa8f6c4430.png

    Forum:
    https://image.prntscr.com/image/1132b56a96134d78b7871bd5949cd3ee.png ??

    Yes twice. It is necessary to come up with a replacement ??
    I has missed. I shall look option.

    Thread Starter Yworld

    (@yworld)

    Solutions have not found ??

    In older topics can be found
    <meta name=”description” content=”<?php bloginfo(‘description’); ?>” />
    In the modern there is no such.

    I regret ??

    Plugin Author Asgaros

    (@asgaros)

    Dont be sad, @yworld ??

    Maybe one day there will be a nice WordPress-core function with filters and hooks so we can easily change it without any problems.

    There is already a ticket on trac for this:
    https://core.trac.www.ads-software.com/ticket/31387

    • This reply was modified 8 years, 3 months ago by Asgaros.
    Thread Starter Yworld

    (@yworld)

    Excellent thank you! ??

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Add meta tags: description and canonical’ is closed to new replies.