WordPress.org

Ready to get started?Download WordPress

Forums

WordPress SEO by Yoast
Customize Meta-Description (5 posts)

  1. RockyMtnHi
    Member
    Posted 11 months ago #

    I am running the Focus Genesis theme and need to modify the title and meta-description based on URL parameters in PHP using $_GET["varname"]. I have successfully modified the <title></title> tag but the description tag is apparently managed entirely by the Yoast SEO plugin and I can't hack around it. I modified the genesis_seo_meta_description function in Genesis then added this to the functions.php:
    add_action( 'genesis_meta', 'genesis_seo_meta_description' );

    Apparently this never gets invoked. These comments surround the entire meta section and I can't change the meta-description because of it:

    <!-- This site is optimized with the Yoast WordPress SEO plugin v1.4.15 - http://yoast.com/wordpress/seo/ -->
    <meta name="description" content="Portable Showers Details - Royal Restrooms-Portable Restroom and Shower Trailer Rentals Portable Toilets, Restrooms and Mobile Shower Trailer Rentals."/>
    <link rel="canonical" href="http://royalrestrooms.com/shower-trailers-city/" />
    <link rel="author" href="https://plus.google.com/115831342701351672346/posts"/>
    <meta property="og:locale" content="en_US"/>
    <meta property="og:type" content="article"/>
    <meta property="og:title" content="Portable Showers Details - Royal Restrooms-Portable Restroom and Shower Trailer Rentals August 28, 2013 4:27 pm"/>
    <meta property="og:description" content="Portable Showers Details - Royal Restrooms-Portable Restroom and Shower Trailer Rentals Portable Toilets, Restrooms and Mobile Shower Trailer Rentals."/>
    <meta property="og:url" content="http://royalrestrooms.com/shower-trailers-city/"/>
    <meta property="og:site_name" content="Royal Restrooms-Portable Restroom and Shower Trailer Rentals"/>
    <meta property="og:image" content="http://royalrestrooms.com/wp-content/uploads/2011/09/RRInt2Shower12-300x210.jpg"/>
    <!-- / Yoast WordPress SEO plugin. -->

    Is there a way to override the Yoast SEO handling of the meta-description section?

    Thanks for the help in advance.

    http://wordpress.org/plugins/wordpress-seo/

  2. astrasuite
    Member
    Posted 11 months ago #

    I keep getting duplicate, short, long descriptions reported by Google Webmaster, so I modified function metadesc under frontend/class-frontend.php. I am no programmer, so my solution may be crude, but I have zero HTML Improvements reports now from Google Webmaster. In the code below, jcr is me.

    First, I commented this out so that I have a description on every page, unlike the default where there is no description for page 2, page 3, etc.

    /* jcr
    		if ( get_query_var( 'paged' ) && get_query_var( 'paged' ) > 1 )
    			return;
    		*/

    And then the following, to have unique description, and long enough. Works great now, even for Nextgen paginations. I added the code before and after the line $metadesc = apply_filters( 'wpseo_metadesc', trim( $metadesc ) );

    // jcr - get current url, post id
    		global $wp, $jcr_current_url, $jcr_post_id;
    		$jcr_current_url = add_query_arg( '', '', home_url( $wp->request ) );
    		$jcr_current_url = str_replace('/','',$jcr_current_url);
    		$jcr_current_url = str_replace('-','',$jcr_current_url);
    		$jcr_current_url = substr($jcr_current_url, -15);
    		$jcr_post_id = get_the_ID();
    
    		$metadesc = apply_filters( 'wpseo_metadesc', trim( $metadesc ) );
    		if ( !empty( $metadesc ) )	{
    			$metadesc = substr(esc_attr( strip_tags( stripslashes( $metadesc ) ) ),0,120) . ' /' . $jcr_post_id . $jcr_current_url;
    			if (strlen($metadesc) < 130)
    				$metadesc = $metadesc . ' / We are suppliers of top class high-end audio';
    			if (strlen($metadesc) < 100)
    				$metadesc = $metadesc . ' / high fidelity equipment that respect music, with emotion';
    		}
    
    		if ( $echo !== false ) {
    			if ( !empty( $metadesc ) )
    				echo '<meta name="description" content="' . $metadesc . '"/>' . "\n";
    			else if ( current_user_can( 'manage_options' ) && is_singular() )
    				echo '<!-- ' . __( 'Admin only notice: this page doesn\'t show a meta description because it doesn\'t have one, either write it for this page specifically or go into the SEO -> Titles menu and set up a template.', 'wordpress-seo' ) . ' -->' . "\n";
    		} else {
    			return $metadesc;
    		}
  3. mommysplurge
    Member
    Posted 11 months ago #

    have any ideas on mine? http://wordpress.org/support/topic/need-help-running-shortcodes-on-description?replies=1

    I have a related issue - I want to use a custom field as my excerpt, but i need to be able to run the shortcodes on it. anything i do creates the right description, but then my post doesn't display at all. I'm totally baffled. I've tried metadesc = do shortcode, apply filters/do_shortcode etc.

    what you were doing seemed similar, sorry to barge in, but if you have ideas...! :) thanks!

  4. RockyMtnHi
    Member
    Posted 11 months ago #

    I haven't received a solution to this, so I am wondering if it is possible to use the Headspace 2 SEO plugin and import the Yoast SEO title and meta description info?

  5. kutuliskan
    Member
    Posted 5 months ago #

    Hi Sir, i suggesting you to follow this action...
    You can remove this text or message easily.Just follow these step.
    You have open wordpress seo plugin folder by FTP or Cpanel file manager or Open wordpress plugin editor.
    Method One FTP:
    -Login with your FTP app by user name password and ftp host.
    -open Your wp-content
    -open plugin folder
    -open wordpress seo folder
    -open fontend folder
    -open class-frontend.php file
    -find the line

    add_action( 'wpseo_head', array( $this, 'debug_marker' ), 2 );

    -You will find a group of add_action there like below-

    add_action( 'wpseo_head', array( $this, 'debug_marker' ), 2 );
    add_action( 'wpseo_head', array( $this, 'robots' ), 6 );
    add_action( 'wpseo_head', array( $this, 'metadesc' ), 10 );
    add_action( 'wpseo_head', array( $this, 'metakeywords' ), 11 );
    add_action( 'wpseo_head', array( $this, 'canonical' ), 20 );
    add_action( 'wpseo_head', array( $this, 'adjacent_rel_links' ), 21 );
    add_action( 'wpseo_head', array( $this, 'author' ), 22 );
    add_action( 'wpseo_head', array( $this, 'publisher' ), 23 );

    -Just Remove the first line from here.
    -and Find and remove below line.

    echo "nn";

    -Save the file.
    and You have done it. check there is no unwanted message there.
    Cpanel and FTP is a same process.But if you want to do via plugin editor. You have to open class-frontend.php edit follow these instruction. Causion Make a backup before edit the file.

Reply

You must log in to post.

About this Plugin

About this Topic