Tag Info

New answers tagged

0

I found that the previous answer, as stated in the comments, only works when saving an existing post and not new posts. The below will work for new posts and existing posts. // func that is going to set our title of our customer magically function w2w_customers_set_title( $data , $postarr ) { // We only care if it's our customer if( $data[ ...


0

Ok solved. <?php if ( is_front_page() && !is_home() ) :?> <h1><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1> <?php elseif ( is_home() && get_option('page_for_posts') ): ?> <h1><?php echo apply_filters('the_title',get_page( ...


0

There's actually some cool filters that allow you to pre-populate the title field and editor field, the one we need is default_title. Once in the hook, we need to get our user and display the name: function post_author_title( $post_title, $post ) { if( $post->post_type == 'your_post_type' ) { $user = wp_get_current_user(); ...


0

Without knowing the surrounding code, it is hard to tell what the problem might be, but you said you checked the $post variable. Maybe the $post variable is not set properly, the save_post action only gives you the post id: function get_post_title($post_id) { $post = get_post($post_id); if (empty($post->post_title)) { // No title set, put in ...


2

to show the page title for the page set as the 'blog' or 'posts page', you need to add some code, maybe via a filter on wp_title(); example: add_filter( 'wp_title', 'wpse_174379_show_posts_page_wp_title' ); function wpse_174379_show_posts_page_wp_title( $title ) { if( get_option( 'page_for_posts' ) ) { $posts_page = get_post( get_option( ...


0

In the end I managed to use this: function getUrl() { $url = 'http' . ( isset( $_SERVER['HTTPS'] ) && 'on' === $_SERVER['HTTPS'] ) ? 's' : ''; $url .= '://' . $_SERVER["SERVER_NAME"]; $url .= $_SERVER['REQUEST_URI']; return $url; } This goes in the functions.php and what is does is retrieves the page url. function writeUrl() { echo ...


0

In a normal post when you add an image, the WordPress editor adds the title to the img tag, not to the surrounding a tag. If both tags had different titles the title of the img tag would be displayed by the browser, not the title of the a tag. Using your original example, I have added a title attribute to the img tag: <a href="path_to_files/image.jpg" ...


1

If your theme is using add_theme_support('title-tag'), then you can try the following: remove_action( 'wp_head', '_wp_render_title_tag', 1 ); and then just hook in your own modified version: add_action( 'wp_head', 'wpse_render_title_tag_with_itemprop', 1 ); function wpse_render_title_tag_with_itemprop() { if ( did_action( 'wp_head' ) || ...



Top 50 recent answers are included