• Resolved Tamas Rottenbacher

    (@rtomo)


    Hey!

    I’m trying add header facebook og:title for my theme.

    That’s the code:

    add_action( 'wp_head', 'rotisoft_meta_cim' );
    function rotisoft_meta_cim()
    {
    	echo '<meta property="og:title" content="';
    
    if ( is_page('117') ) {
    
    	echo "Blog Site Title";
    }
    
    elseif ( is_front_page() ) {
    
        bloginfo( 'name' );
    	echo " | MySyite description";
    } 
    
    elseif ( is_page() ) {
    
    	echo "MySite | ";
    	echo get_the_title();
    
    } elseif ( is_category() ) {
    
    	echo "Mysite Category: ";
    	single_cat_title();
    
    } elseif ( is_tag() ) {
    
    	echo "MySite tag: ";
    	single_tag_title('');
    
    } elseif ( is_single() ) {
    
        bloginfo( 'name' );
    	echo " | ";
    	the_title();
    
    } else {
    
        bloginfo( 'name' );
    	echo " | ";
    	the_title();
    
    }
    	echo '">' . "\n" ;
    }

    The problem: When i’m look the 117 id’s site, the title is the latest blog post title. (Don’t the _Blog Site Title_.)

    I’m testing thats codes:
    if ( is_page(117,'blog','Blog') )

    I’m read that page: https://codex.www.ads-software.com/Function_Reference/is_page
    But, i’m don’t know, what is the problem. ??

    Thx for help!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    Try using is_page() once:

    add_action( 'wp_head', 'rotisoft_meta_cim' );
    function rotisoft_meta_cim()
    {
    	echo '<meta property="og:title" content="';
    
    if ( is_page() ) {
      if ( is_page('117') ) {
    	echo "Blog Site Title";
      } else {
        echo "MySite | ";
        echo get_the_title();
      }
    }
    
    elseif ( is_front_page() ) {
    
        bloginfo( 'name' );
    	echo " | MySyite description";
    }
    elseif ( is_category() ) {
    
    	echo "Mysite Category: ";
    	single_cat_title();
    
    } elseif ( is_tag() ) {
    
    	echo "MySite tag: ";
    	single_tag_title('');
    
    } elseif ( is_single() ) {
    
        bloginfo( 'name' );
    	echo " | ";
    	the_title();
    
    } else {
    
        bloginfo( 'name' );
    	echo " | ";
    	the_title();
    
    }
    	echo '">' . "\n" ;
    }

    Michael

    (@alchymyth)

    if you are targeting the ‘posts page’, i.e. the page that you have set to show the latest posts, try to use:

    is_home()

    https://codex.www.ads-software.com/Conditional_Tags#The_Main_Page

    Thread Starter Tamas Rottenbacher

    (@rtomo)

    @keesiemeijer: not working. =/

    I’m trying with the theme framework costum fields, and it solved the problem.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Not working: if is_page()’ is closed to new replies.