如何显示wordpress网站标题和标语?

时间:2016-02-08 12:33:01

标签: php wordpress

我正在尝试将网站标题和标语放在子主题标题中。我搜索了它,找到了这两个不同的wordpress函数get_bloginfo()bloginfo()

package com.example.trynot; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import java.util.Locale; import com.example.trynot.MainActivity.ReadMailSample; import android.app.Activity; import android.os.Bundle; import android.speech.tts.TextToSpeech; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; public class Notify extends Activity implements TextToSpeech.OnInitListener { /** Called when the activity is first created. */ public TextToSpeech tts = new TextToSpeech(MainActivity.c, Notify.this); public Notify() { System.out.println("Inside Constructor"); speakOut(); } @Override public void onDestroy() { // Don't forget to shutdown tts! if (tts != null) { tts.stop(); tts.shutdown(); } super.onDestroy(); } @Override public void onInit(int status) { System.out.println("inside INIT"); if (status == TextToSpeech.SUCCESS) { int result = tts.setLanguage(Locale.US); tts.speak(MainActivity.ReadMailSample.command, TextToSpeech.QUEUE_FLUSH, null); if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) { Log.e("TTS", "This Language is not supported"); } else { speakOut(); } } else { Log.e("TTS", "Initilization Failed!"); } } private void speakOut() { System.out.println("inside SPeak out"); tts.speak(MainActivity.ReadMailSample.command, TextToSpeech.QUEUE_FLUSH, null); } } 未显示标语,get_bloginfo()同时显示网站标题和标语。问题是bloginfo()正在删除网站标题和说明之间的bloginfo()和空格。

:

标题:网站这是示例网站。

您可以看到<title><?php bloginfo( 'name' ) . ' : '. bloginfo( 'description' ); ?></title> Website之间没有空格。

所以我可以使用适当的空格和This显示网站标题和标语吗?

2 个答案:

答案 0 :(得分:11)

这会对你有帮助。

<title> 
<?php
	$site_description = get_bloginfo( 'description', 'display' );
	$site_name = get_bloginfo( 'name' );
    //for home page
	if ( $site_description && ( is_home() || is_front_page() ) ):
		echo $site_name;echo ' | '; echo  $site_description; 
	endif;
	// for other post pages
	if (!( is_home() ) && ! is_404() ):
	the_title(); echo ' | '; echo $site_name;
	endif;
	?>
</title>

答案 1 :(得分:3)

试试这个

<title><?php echo get_bloginfo( 'name' ) . ' : '. get_bloginfo( 'description' ); ?></title>

echo get_option('blogname'); // For Site Name
echo get_option('blogdescription'); // For Tag line or description