Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have the code base for my Wordpress theme, but where do I start debugging where the meta description tag is set for my theme.

What I need to do is make it not be set because I set my descriptions in the Yoast plugin.

I did a grep for this:

"<meta name=\"description\""

But the files it returned didn't seem to be the ones I needed. Would anyone know what is the right way to locate where the description tag for categories is set in the theme?

I am using a Suffusion theme.

EDIT:

This is my header.php

<?php
/**
 * Core header file, invoked by the get_header() function
 *
 * @package Suffusion
 * @subpackage Templates
 */

global $suffusion_unified_options, $suffusion_interactive_text_fields, $suffusion_translatable_fields, $suffusion_skin_dependence, $suf_color_scheme;
if (function_exists('icl_t')) {
    foreach ($suffusion_unified_options as $id => $value) {
        /**
         * Some strings are set interactively in the admin screens of Suffusion. If you have WPML installed, then there may be translations of such strings.
         * This code ensures that such translations are picked up, then the unified options array is rewritten so that subsequent calls can pick it up.
         */
        if (function_exists('icl_t') && in_array($id, $suffusion_translatable_fields) && isset($suffusion_interactive_text_fields[$id])) {
            $value = wpml_t('suffusion-interactive', $suffusion_interactive_text_fields[$id]."|".$id, $value);
        }
        global $$id;
        $$id = $value;
        $suffusion_unified_options[$id] = $value;
    }
}

$queried_id = get_queried_object_id();
$hidden_elements = array();
if ($queried_id != 0) {
    $hide_top_navigation = suffusion_get_post_meta($queried_id, 'suf_hide_top_navigation', true);
    if ($hide_top_navigation) {
        add_filter('suffusion_can_display_top_navigation', 'suffusion_disable_component_for_view');
        $hidden_elements[] = 'no-top-nav';
    }
    $hide_main_navigation = suffusion_get_post_meta($queried_id, 'suf_hide_main_navigation', true);
    if ($hide_main_navigation) {
        add_filter('suffusion_can_display_main_navigation', 'suffusion_disable_component_for_view');
        $hidden_elements[] = 'no-main-nav';
    }
    $hide_header = suffusion_get_post_meta($queried_id, 'suf_hide_header', true);
    if ($hide_header) {
        add_filter('suffusion_can_display_header', 'suffusion_disable_component_for_view');
        $hidden_elements[] = 'no-header';
    }
    $hide_footer = suffusion_get_post_meta($queried_id, 'suf_hide_footer', true);
    if ($hide_footer) {
        add_filter('suffusion_can_display_site_footer', 'suffusion_disable_component_for_view');
        $hidden_elements[] = 'no-site-footer';
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>

<head profile="http://gmpg.org/xfn/11">
    <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
    <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />

<?php
    suffusion_document_header();
    $suffusion_pseudo_template = suffusion_get_pseudo_template_class();
    if (is_singular()) {
        wp_enqueue_script('comment-reply');
    }
    $skin = isset($suf_color_scheme) ? $suf_color_scheme : 'light-theme-gray-1';
    $extra_classes = $suffusion_pseudo_template;
    if (isset($suffusion_skin_dependence[$skin])) {
        $extra_classes = array_merge($extra_classes, $suffusion_skin_dependence[$skin]);
    }
    $extra_classes[] = $skin;
    $extra_classes = array_merge($extra_classes, $hidden_elements);
    wp_head();  
?>
</head>

<body <?php body_class($extra_classes); ?>>
    <?php suffusion_before_page(); ?>
        <?php
            suffusion_before_begin_wrapper();
        ?>
        <div id="wrapper" class="fix">
        <?php
            suffusion_after_begin_wrapper();
        ?>
            <div id="container" class="fix">
                <?php
                    suffusion_after_begin_container();
                ?>

EDIT 2:

When I did a grep for suffusion_document_header, I got these results:

/Users/owner12/Desktop/G33kTalk/wp-content/themes/suffusion/functions (1:11:13 6:44 PM).php:    add_action('suffusion_document_header', 'suffusion_include_ie7_compatibility_mode');
/Users/owner12/Desktop/G33kTalk/wp-content/themes/suffusion/functions (1:11:13 6:44 PM).php:    add_action('suffusion_document_header', 'suffusion_set_title');
/Users/owner12/Desktop/G33kTalk/wp-content/themes/suffusion/functions (1:11:13 6:44 PM).php:    add_action('suffusion_document_header', 'suffusion_include_meta');
/Users/owner12/Desktop/G33kTalk/wp-content/themes/suffusion/functions (1:11:13 6:44 PM).php:    add_action('suffusion_document_header', 'suffusion_include_favicon');
/Users/owner12/Desktop/G33kTalk/wp-content/themes/suffusion/functions (1:11:13 6:44 PM).php:    add_action('suffusion_document_header', 'suffusion_include_default_feed');
/Users/owner12/Desktop/G33kTalk/wp-content/themes/suffusion/functions.php:  add_action('suffusion_document_header', 'suffusion_include_ie7_compatibility_mode');

EDIT 3:

This is the seo.php

<?php
/**
 * This file handles SEO in Suffusion. It is not to be loaded directly, but is instead loaded from different templates.
 * Users can override this in a child theme by creating a file in an "inserts" directory called seo.php.
 *
 * @package Suffusion
 * @subpackage Templates
 */

global $suf_seo_enabled, $suf_seo_all_settings;
if ($suf_seo_enabled == 'enabled') {
    $seo_settings = explode(',', $suf_seo_all_settings);
    if (is_array($seo_settings)) {
        if (in_array('generator', $seo_settings)) {
            wp_generator();
        }

        if (in_array('theme', $seo_settings)) {
            $theme_data = get_theme_data(get_template_directory().'/style.css');
            echo "\t".'<meta name="template" content="'.esc_attr("{$theme_data['Title']} {$theme_data['Version']}").'" />'."\n";
        }

        if (in_array('robots', $seo_settings) && get_option('blog_public')) {
            echo "\t".'<meta name="robots" content="noindex,nofollow" />' . "\n";
        }

        if (in_array('author', $seo_settings)) {
            global $wp_query;
            if (is_singular()) {
                $author = get_the_author_meta('display_name', $wp_query->post->post_author);
            }
            else {
                $posts_on_page = $wp_query->posts;
                $author_array = array();
                foreach ($posts_on_page as $single_post) {
                    $single_author = get_the_author_meta('display_name', $single_post->post_author);
                    if (!in_array($single_author, $author_array)) {
                        $author_array[] = get_the_author_meta('display_name', $single_post->post_author);
                    }
                }
                $author = implode(',',$author_array);
            }

            if ($author) {
                echo "\t".'<meta name="author" content="'.esc_attr($author).'" />' . "\n";
            }
        }

        if (in_array('copyright', $seo_settings)) {
            if (is_singular()) {
                $copy_date = sprintf(get_the_time(get_option('date_format')));
            }
            else {
                $copy_date = date('Y');
            }
            echo "\t".'<meta name="copyright" content="'.sprintf(esc_attr__('Copyright (c) %1$s', 'suffusion'), $copy_date).'" />'."\n";
        }

        if (in_array('revised', $seo_settings)) {
            if (is_singular()) {
                $mod_time = sprintf(get_the_modified_time(get_option('date_format')." ".get_option('time_format')));
                echo "\t".'<meta name="revised" content="'.$mod_time.'" />'."\n";
            }
        }

    }

    global $suf_seo_meta_description, $wp_query;
    if (is_home()) {
        $description = $suf_seo_meta_description;
    }
    else if (is_singular()) {
        $description = suffusion_get_post_meta($wp_query->post->ID, "meta_description", true);
        if (empty($description) && is_front_page()) {
            $description = $suf_seo_meta_description;
        }
    }
    else if (is_category() || is_tag() || is_tax()) {
        $description = term_description('', get_query_var('taxonomy'));
    }
    else if (is_author()) {
        $description = get_the_author_meta('description', get_query_var('author'));
    }
    if (!empty($description)) {
        $description = stripslashes($description);
        $description = strip_tags($description);
        $description = str_replace(array("\r", "\n", "\t"), '', $description);
        $description = "\t".'<meta name="description" content="' . $description . '" />' . "\n";
        echo $description;
    }

    global $suf_seo_meta_keywords;
    if (is_home() || is_category() || is_tag() || is_tax() || is_author()) {
        $keywords = $suf_seo_meta_keywords;
    }
    else if (is_singular()) {
        $keywords = suffusion_get_post_meta($wp_query->post->ID, "meta_keywords", true);
        if (empty($keywords)) {
            $keywords = $suf_seo_meta_keywords;
        }
    }

    if (isset($keywords) && !empty($keywords)) {
        $keywords = stripslashes($keywords);
        $keywords = strip_tags($keywords);
        $keywords = str_replace(array("\r", "\n", "\t"), '', $keywords);
        $keywords = str_replace(array(", ", " ,"), ',', $keywords);
        $keywords = "\t".'<meta name="keywords" content="' . $keywords . '" />' . "\n";
        echo $keywords;
    }
}
?>
share|improve this question
    
The meta is probably set in header.php, or by a function in functions.php, the function in functions.php would then probably output meta information in the header. So the function may be called in header.php or i could be outputted using the header hook. –  Ronburgundy Jul 18 '13 at 15:02
    
@Ronburgundy thank you Ron, I just updated my original question with the header.php –  Genadinik Jul 18 '13 at 15:04
    
Would you know where the functions.php is located? –  Genadinik Jul 18 '13 at 15:05
    
I dont see a meta for description in the header. The functions.php file is located in the same directory as header.php –  Ronburgundy Jul 18 '13 at 15:09
    
That theme uses a break down of functions.php into several functions files located in themename/functions/filename it appears so tracking it down may be difficult. If the site even sets the description meta. –  Ronburgundy Jul 18 '13 at 15:11

1 Answer 1

up vote 1 down vote accepted

in seo.php in the custom folder line 73

global $suf_seo_meta_description, $wp_query;
if (is_home()) {
    $description = $suf_seo_meta_description;
}
else if (is_singular()) {
    $description = suffusion_get_post_meta($wp_query->post->ID, "suf_meta_description", true);
    if (empty($description)) { // Check the old meta field
        $description = suffusion_get_post_meta($wp_query->post->ID, "meta_description", true);
    }
    if (empty($description) && is_front_page()) {
        $description = $suf_seo_meta_description;
    }
}
else if (is_category() || is_tag() || is_tax()) {
    $description = term_description('', get_query_var('taxonomy'));
}
else if (is_author()) {
    $description = get_the_author_meta('description', get_query_var('author'));
}
if (!empty($description)) {
    $description = stripslashes($description);
    $description = strip_tags($description);
    $description = str_replace(array("\r", "\n", "\t"), '', $description);
    $description = "\t".'<meta name="description" content="' . $description . '" />' . "\n";
    echo $description;
}
share|improve this answer
    
I thought the issue was line 78 to 81, no? –  Genadinik Jul 18 '13 at 16:37
    
I am not sure if the is_singular() that we want. I thought it was the is_category() that we are after. But I am not sure what is the is_singular() line. What does is_singlar() line determine? Thank you!! –  Genadinik Jul 18 '13 at 16:39
    
From googling, I saw that is_singular() tag enables you to target single-view pages, regular page pages, and attachment pages. But how do I know which of my pages are single-view pages? :) –  Genadinik Jul 18 '13 at 16:46
    
When you click on a post title, or click view post, that is a single or singular post / page. Pretty much if you are only looking at one post / page, that is singular. Like this oq.publicvent.org/banned-from-vent-want-to-appeal is a single page because we are looking at just that one post. –  Ronburgundy Jul 18 '13 at 17:01
    
If your looking to stop the description being set on the categories you can delete these lines; else if (is_category() || is_tag() || is_tax()) { $description = term_description('', get_query_var('taxonomy')); } ... I think lol. (line 78) –  Ronburgundy Jul 18 '13 at 17:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.