How to intercept Post Title on Post-Save

I am new to WP and I couldn’t find this solution by myself. this is my function, function explodetitletotags() { global $post; $title = $post->post_title; $tags = explode(‘ ‘, preg_replace(‘/[^\p{L}0-9 ]/’, ‘ ‘, $title)); foreach $tags as $tag { global $post; $thePostID = $post->ID; wp_add_post_tags($thePostID, $tag); } } add_action(‘publish_post’, ‘explodetitletotags’); The Function works like a … Read more

Multiple Conditions for Child Page Title

I’ve been trying to work with Conditional Tags and cannot wrap my head around this problem. PHP novice here. On sub-pages I need to display the parent page title as well as the page title. I have it working with this: <h1><?php echo get_the_title($post->post_parent);?></h1> <h2><?php the_title(); ?></h2> But the problem I have now is that … Read more

How to display thumbnail + tags + title of a child page?

What do I need to do to display thumbnail + tags + title of a child page? [ Thumbnail ] [ Title ] [ Tags ] Thanks! EDIT: Well this work, but only showing thumbs+title… it shouldnt be too difficult to add the tags: <?php $child_pages = $wpdb->get_results(“SELECT * FROM $wpdb->posts WHERE post_parent = “.$post->ID.” … Read more

get the_title_attribute by id

I’m creating a list with a few permalinks which I call to with <a href=”https://wordpress.stackexchange.com/questions/111931/<?php echo get_permalink($id); ?>” title=”…. And for the title I want to call the_title_attribute(). But it seems it can only be called within a loop, and not by id. How do I correctly get a title attribute? Note: The reason I … Read more

Replacing the title in admin list table

Here is my situation: I am trying to filter the content of the title column in my custom post type edit table but I can’t get it working. Here is what I have tried: add_filter(‘manage_edit-mycpt_columns’, ‘replace_title_products’); function replace_title_products() { $oldtitle = get_the_title(); $newtitle = str_replace(array(“<span class=”sub-title”>”, “</span>”), array(“”, “”),$oldtitle); $title = esc_attr($newtitle); return $title; } … Read more

How to get page’s ID if I know the title only?

Is there an exact opposite funciton to this one: get_the_title(ID) I know there’s: get_the_id() But it doesn’t seem to accept any arguments. So, basically, I’m looking for something like: $title=”Something”; get_the_id($title); I already know this solution: global $wpdb; $post_name = get_query_var(‘name’); $post_id = $wpdb->get_var(“SELECT ID FROM $wpdb->posts WHERE post_name = $post_name”); But maybe there’s something … Read more