Support » Fixing WordPress » How to put the_title() in the middle of the_content()?

  • I’m trying to put “the_title()”, “the_permalink()” and others tags in the middle of “the_content()”.

    I’m thinking about “explode()” the content and mount the template code. The problem is that I have no idea how to explode the “the_content()” function.

    I know how to do it using one plugin, cause I get the post content without the “the_content()” function but how can I mount the post in one plugin?? I can’t use the functions like “the_tile()”, “the_permalink()” etc.

    So, if I use one plugin how can I get the post title and other tags?

    And I really need one plugin? Don’t have any away to explode the “the_content” function?

    Thanks.

Viewing 8 replies - 1 through 8 (of 8 total)
  • be more explicit on your request. As far as i understand you want to place the title of the post as a centered text in the post placement on the screen and the content aligned left or justify, right?
    Why then not try this?

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

    where .centered{text-align:center}?

    You simply enclose the code that exists in the loop with a centered div. Look in the loop for the text that displays your title.

    Hope this helps.

    Oh, no… I’m not talking about styles.

    I need explode – using the PHP function explode() – the post content cause I need broke my post in 3 parts and mount it in different places in my template. But there are a lot of ways to do it and I’m trying with one plugin.

    So, actually my question is: which variable should I use in my plugin page to get the currently post title? Cause the function “the_title()” don’t work.

    Thanks for your reply, and sorry my english. I hope you can understand now.

    you do not need to use Explode(). It wont do what you are asking efficiently, if at all.

    “Explode Returns an array of strings, each of which is a substring of string formed by splitting it on boundaries formed by the string separator. If limit is set, the returned array will contain a maximum of limit elements with the last element containing the rest of string.”
    http://uk2.php.net/explode

    the_title() is the call for the post title, unless you have modified it

    the_title() function don’t work in the plugin page…
    to get the content I use:

    function my_function($content) {
    (…)
    }

    so $content will be the post content. But how can I get the post title?

    look at your loop and see what your title is renamed as.

    When I use the “the_title()” function in one template file it works great. But I’m trying to get this value in one plugin page, and I don’t know why, but it don’t work.

    I can get the post content in my plugin page using this code:

    function my_function($content) {
    (…)
    }

    the variable $content is the post content. But how to get the post title and the post permalink??

    Thanks.

    But how to get the post title and the post permalink??

    function my_function($content) {

    global $wp_query;

    $post_title = $wp_query->post->post_title;
    $post_link = get_permalink($wp_query->post->ID);

    (...)
    }

    Thanks!! Now it works great!! =)

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How to put the_title() in the middle of the_content()?’ is closed to new replies.