Tag Info

New answers tagged

1

Set the display argument of the function to false. <h2> <?php if (is_category()){ echo 'Category: ' . single_cat_title( '', false); } ?> </h2> Or, to use the function in its more "helpful" form you could do: single_cat_title('Category: '); If the display argument is true, WordPress automatically ...


1

First, let's change your <title> to <title><?php wp_title(' | ', true, 'right'); ?></title> Because adding to the title string in that was isn't very future-forward, instead it's best to use a filter to do any modifications to the title. So let's instead ad (in functions.php): add_filter('wp_title', 'my_custom_title'); function ...


1

You may want to filter out the title. add_filter( 'wp_title', 'wpse179527_wp_title' ); function wpse179527_wp_title( $title ) { global $post; if ( is_single() && 'custom-post' == get_post_type( $post ) ) return ''; return $title; }


1

You can make use of properties on elements. Have a look at the following concept and see if you can use it. You basically hide all "featured" images. Add a general class to the post titles which you want to use to show/hide images. Add a property to the post title element which holds the id of the image you want to show. Generated MarkUp: <img ...


2

the_title() calls your function again. If you want to avoid that, remove the callback inside of your function: function filter_title_after() { remove_filter( current_filter(), __FUNCTION__ ); // the rest of your code. But you shouldn’t call the_title() in your function at all: it prints the title – this is not what you want – and you get the ...


0

You can use the wp_trim_excerpt() function. If you want need to specify chars limit, you should be able to use the excerpt_length filter. <?php echo wp_trim_excerpt( get_the_title() ); ?>


1

Try this to create your custom titles. remove_filter( 'wp_title', 'genesis_default_title', 10, 3 ); //Default title remove_action( 'genesis_site_title', 'genesis_seo_site_title' ); //Genesis Extra Stuff remove_action( 'genesis_site_description', 'genesis_seo_site_description' ); //Genesis Extra Stuff add_filter( 'wp_title', 'genesis_default_title_new', 10, ...


3

From the Codex If you are using a custom homepage with custom loops and stuff or a custom front-page, you will have an empty wp_title. Here goes a neat hack to add the description/tagline at the wp_title place on homepage: add_filter( 'wp_title', 'baw_hack_wp_title_for_home' ); function baw_hack_wp_title_for_home( $title ) { if( empty( $title ) ...


6

It looks like your site's title is empty. Fill it out or try for example: add_filter( 'wp_title', function( $title ) { return trim( $title ); } ); to remove the blank space in front. For your setup, the following part of wp_title() is responsible for the blank space: $title = $prefix . implode( " $sep ", $title_array ); So when you're on a single ...


0

Strange. Outside the loop, the_title() should give you the current page name, if you really are on a page, and not viewing a specific post. If it gives post title instead, it may mean that you are somehow inside a loop. But if that were true, wp_title shouldn't show "Blog". See if other options give the same result: //the_title(); single_post_title(); echo ...


0

Without all the info of what is actually happening I'm assuming that the title is output with the Song Artist and the Song Name together. But like you said with a dash in the middle. With that assumption, then you can accomplish this with a custom function that filters the_title before it's output. Try putting this in your functions.php file: function ...


0

You have to put song title into <span> tag and .classOfContainer span{color:red;}


0

The filter wp_title changes only the function wp_title() when it's called. So, you must double check on your theme's source code if before your header is using wp_title. Anyway, you can set your filter on functions.php. A function to identify your param GET should be something like so: function maybe_change_wp_title_ver( $title, $sep ) { if ( isset( ...


0

This works fine for me when i test it. I did edit your code as you had a small error in the function name not matching. Also, you might want to add a conditional tag and wrap the shortcode in a div but otherwise it works. function adt_abovetitle($title){ //Return new title if called inside loop if ( in_the_loop() && is_singular('post') ...


3

Your problem is that you can not use wp_title() in the theme if the theme already supports title-tag. The <head> of your theme should look like this: <head> <meta charset="<?php bloginfo( 'charset' ); ?>"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <?php wp_head(); ?> </head> ...


2

I've found a solution, so I'm sure it will be useful for others. First: custom titles Explanation: If my custom_titles() function is enabled, load the function in functions.php under the after_theme_setup priority 2, and show the title tags in the header.php file. In functions.php: if ( ot_get_option( 'enable_custom_titles' ) === 'on' ) { // The ...



Top 50 recent answers are included