So I would like to replace the entire title of posts in WordPress bases on user behaviuor and role. Please note that I would like to replace the entire post title and not the prepend or append text to it. Each post has a 'default' title, which is the title of the post, like "Make No.1245/12.02.2022 on model 2376/2021". The alternative title would be "Make No.*******/********.2022 on model *******/2021" basically replacing certain parts of the title with asterisks, essentially hiding …
I cannot get the main blog page with the current blog to show the current blog title. It shows on all other pages, just not the current/most recent blog. Any help will be greatly appreciated. Thank you. <div id="page"> <div id="contentleft"> <?php if ( $paged < 2 ) { // Do stuff specific to first page?> <?php $my_query = new WP_Query('category_name=featured&showposts=1'); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID;?> <div class="featurepost" id="post-<?php the_ID(); ?>"> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link …
I want to get all posts which are starting with a number (0-9) or symbols, in a list. I managed to get it work for letters, but this one is harder for me. Can someone help me out please? I tried adding this in my existing code, but it didn't work: $this_char = strtoupper(mb_substr($post->post_title, 0, 1, 'UTF-8')); if (strpos('0123456789',$this_char) !== false) $this_char = '0-9'; if ($this_char != $last_char) { This is my code: <?php $first_char = 'A'; $postids=$wpdb->get_col($wpdb->prepare(" SELECT ID …
I have built a custom query for a website where I have a custom post type named "Program" (i.e). On this custom post type, let's say I have the taxonomy "Level" where I have some choices. The way I have built the code, you can create as many page with the same title but with different taxonomies. On the frontend, I use a custom WP_Query to fetch all posts with the same title and display a menu to link them …
tell me how permanent the links to change the splitter from vertical to horizontal of the main page write website. | — http://joxi.ru/a2XlxQXcyeKPj2 The name of the site | short name The name of the site — short name
I would like to remove the "private" prefix for each post title. I found the filter here. I managed to removed the word "Private" but when I concatenate with " : ". That does not work anymore. I checked $title value before the str_replace and it´s already translated with " : ". Class FrontEnd{ protected function front_end_init() { add_filter( 'the_title', array( $this, 'remove_private_prefix' ) ); } public static function remove_private_prefix( $title ) { $title = str_replace( __( 'Private' ) . …
I'm using get_posts() to fetch posts from a particular category to display at the top of my homepage, separate from the main homepage Loop. Everything seems to work fine, but for the title (returned through the_title()) which is always the same; the title of the first post fetched by get_posts(). the_permalink() does the same as well, but the_excerpt() returns the correct result for each post. Here's my code (I have removed only a few lines for fear I might inadvertently …
function get_post_data(){ $post_id = $_POST['post_id']; ... $data['title'] = get_the_title( $post_id ); ... $data['excerpt'] = get_the_excerpt( $post_id ); ... echo json_encode( $data ); wp_die(); } The above code shows the scheme of the ajax call. Some data should be retriven from a post given by its ID outside the LOOP. This seems to work when the content fields like title and excerpt not empty. But when empty I get an Internal Server Error (500: admin-ajax.php not found). When I debug the …
I am using the_title filter to add an HTML snippet under the title, as follows: I only want the output to happen for the main title in the posts or page view. That's why I added an early return to make sure that the filter only applies if is_singular() returns true: if ( ! is_singular() ) { return; } But there is an issue, since the title may be loaded in other places inside the single view template. For example, …
I've coded a shortcode to add manually to specific post title fields so i can style part of a title add_shortcode( 'green', 'green_shortcode' ); function green_shortcode( $atts, $content = 0 ) { $a = shortcode_atts( array( 'class' => 'green', ), $atts ); return '<span class="' . $a['class'] . '">' . $content . '</span>'; } This works on the single post titles but doesn't parse the shortcode when pulling the title into a slider. This is the messed up HTML output …
I want to display the Recent Posts Widget title on a page, however I could not find a solution yet. I dont want to display the recent posts on the page only the title of the most recent posts widget, given by user. Is there a simple way to do that? Thank you in advance
I modified the site title the 'the_title' filter. I am using ACF pro repeater, I want to achieve is that if there is content in the repeater a + will be added to the post title. I wrote this script: function mm_title_update( $title, $id = null ) { if ( ! is_admin() && ! is_null( $id ) ) { $post = get_post( $id ); if ( $post->post_type == 'info' ) { $is_index = have_rows('index_copy', $post); //acf repeater field //check if …
I Need to Trim the h2.entry-title, including whitespace and special character Only On Homepage, Category Pages, and Tag Pages. (eg. Gowland Remote Control Car – RC Cars Xmas Gifts) I Need All Titles Like This (Gowland Remote Control Car) I need to trim all the characters after “-” Please Help me with this. Thanks
Firstly, add_theme_support( 'title-tag' ); is enabled in my theme. I have two filters to modify titles, this one hooking on to the_title add_filter( 'the_title', 'custom_account_endpoint_titles', 10, 2 ); function custom_account_endpoint_titles( $title ) { // Currently only have conditions here for My Account pages (is_account_page()) // example: if ( isset( $wp_query->query_vars['edit-account'] ) && is_account_page() ) { return $title; } Secondly I have another function which fixed some title issues on Account pages as well (if I do not add this, the …
I am working on a website, and I am using Polylang to translate it to a different language. In my code I want to get a page title, and display it. My issue is I cannot get it by ID or page_by_path because its going to display the English version of the page on every language. For example: I want to display the Contact page title on english Contact and on another language its equivalent translated contact page title. Is …
I'm trying to modify the WordPress page title. However I'm fairly new to WordPress functions, hooks (filters & actions) and so on. What I could achieve is to change and modify WordPress titles in the <body>. I also was able to change to Page title (<head>), but not to modify it. E.g.: Original page title: My house is red Modified page title (| -> is used for seperate examples): My house is green | My house is red and blue …
I am using a static frontpage and a page for my blogposts. In my header.php I want to display the title of the selected page of my blogposts. For example: <?php if( is_home() ) echo '<h1>' . get_the_title() . '</h1>'; ?><nav> ... </nav> But of course get_the_title() returns the first element of the displayed posts and not of the page itself. How can I display the title of the assigned home page?
In tag pages, I want to display specific text if the title containing a specific word. As example: I have a Tag and tag archive page: Yellow Banana And I want to display “cool fruits” in all tag pages that have in title word “Banana”. Can you tell me the code?
I have a WordPress install in which the "post_title" field from the "wp_posts" table is not making it into the WP_Post->post_title variable. So, for a given post in the wp_posts table that has a correct post_title value of say (retrieved via a direct MySQL query): "My First Post" Retrieving the post title via any basic WordPress method, such as: <?php print the_title(); ?> ... or ... <?php $this_post = get_post(); print $this_post->post_title; ?> Instead of the post's title I get …