• Resolved Jan

    (@jrocho)


    Hi!

    I would like to have short page titles in the wp_list_pages() output, but display a longer title on the page itself. Is there a good way to do this?

    Thanks,
    Jan

Viewing 14 replies - 1 through 14 (of 14 total)
  • Something I’ve implemented a few times:

    1. Provide the Page a custom field of ‘title’ with the value being your longer title.

    2. Download, install and activate:

    Custom Title
    Download plugin | View source

    The plugin changes the title (to your custom field) appearing in wp_title() (typically used in the <title> element), the_title(), the_title_rss() (title in feeds) and single_post_title().

    It also has a single user-configurable variable you should know about:

    $custom_key = The custom key the plugin looks for. The default is 'title'.

    If you decide to use a different key, you can edit the variable either through the Plugin Editor in WordPress, or in a text editor off-line.

    Thread Starter Jan

    (@jrocho)

    Thanks! The plugin works in a way. It still displays the long title in the menu however of the page on which I’m currently on. If I go to a different page it changes to the short version. Is there any way to solve this? I always want the short version to be displayed.

    It still displays the long title in the menu however of the page on which I’m currently on.

    Do you know what’s generating the title there? wp_list_pages() only accesses the post title (and my plugin doesn’t hit any hooks in that function). So, what else is going on in your ‘menu?’

    Thread Starter Jan

    (@jrocho)

    If you want a look at the code which generates the menu:

    https://www.scenology.eu/de/menu.txt

    The website with the problem is:

    https://www.scenology.eu/de/

    If you load that page the first tab says “Kolloquium zur Theorie der Szenografie”, if you click on another tab it changes to “Home” (what it’s supposed to be), same goes for the tab “Referenten”. I always placed the short title, like “Home” in the normal title field of my Page and the long title in a custom field called “title”.

    I’m using the K2 theme and WordPress 2.3.1.

    Hmm. At first I was concerned K2 was up to its old ways again, but no, after some weird testing on my part (where I duplicated your results only some of the time!) I tracked down the culprit deep in WordPress’ innards, where evil gnomes make there home…

    Actually, it’s due to the (Walker_Page) class function start_el, which sounds like a citizen of Krypton, but isn’t. It runs the Page title through the ‘the_title’ filter, which my plugin works off of.

    I’m putting together a fixer for this in the plugin, which I’ll upload later tonight. Took some thinking on my part…

    I’m having the same problem right now. I have a long title for my front page, and added custom title of “Home.” When I’m on any other page, the menu displays “Home.” When I’m actually on that front page, it reads the long title.

    Thread Starter Jan

    (@jrocho)

    Yes, I still don’t have a solution. Maybe Kafkaesqui has put together a fix yet?

    Hi all,

    Was there ever a fix for this?

    Thanks

    I paid good money to have the same plugin developed a year ago lol. Unfortunately, we had the same problem begin with 2.2 upgrade and have not found an integrated solution yet. Thanks for sharing and Love to hear if you ever figured anything out.

    Hello All,

    I have found a simple way to add more descriptive page titles that display on the page, while leaving the official page title that is used in the menus. This method also uses custom fields.

    Step 1: Add a custom field to your page. In this example we create a custom field named ‘pagetitle’ and set it’s value to a long, descriptive title that is to be shown on the page.

    Step 2: Edit the page template file (page.php & any other page templates that are being used). This can be done by either using an off-line text editor and ftp, or if the proper permissions are set, simply use the built in Word Press editor (Presentation > Theme Editor > Page Template). Replace the page title code in the template from:

    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    <?php the_title();?>
    </a></h2>

    to:

    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    <?php
    $key="pagetitle";
    if(get_post_meta($post->ID, $key, true)){
       echo get_post_meta($post->ID, $key, true);
    }
    else{
       the_title();
    }
    ?>
    </a></h2>

    This code will first check to see if there is a custom field named ‘pagetitle’ and if so, use it… if not, use the normal title.

    I think the original problem for the OP with Kafkaesqui’s plugin was that he was using it the wrong way.

    By the looks of things, he was putting in the short title in the custom field, instead of putting the LONG title in the custom field, and actually naming the page using the short title.

    Amirite?

    baden03, That is perfect. Been looking for something like this for ages ?? Works a charm.

    Thanks

    Hi all,
    I am brand new to PHP and spent a lot of time investigating this issue. I too was displaying the tag line only in my <titles> and wasn’t dynamically serving up the post title in the title tags on single posts. Instead of installing a plug in, I wrote an ‘if then’ statement in PHP. Feel free to use the below code. For the arrorw, use ‘&rauquo’

    <title>

    <?php

    if (is_single())
    {
    bloginfo(‘name’); wp_title();
    }

    ?>

    <?php

    if (is_home())
    {
    echo ‘GadgetReview » Tech News and Gadget Reviews’;
    }

    ?>

    <?php

    if (is_category())
    {

    bloginfo(‘name’); wp_title();

    }

    ?>

    </title>

    Many thanks for the perfect solution, baden03!
    You have saved me a lot of headache ??

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Different Page Title for wp_list_pages();’ is closed to new replies.