WordPress.org

Ready to get started?Download WordPress

Forums

Last Viewed Posts
[resolved] Using [shortcode] in title. (4 posts)

  1. energykick
    Member
    Posted 1 year ago #

    So far I love this plugin but I use shortcodes in my title and access them with get_the_title() which has always worked. I have the title to shortcode enabled on my site. My problem is I cannot figure out where (if it is possible) to change the title output to do my shortcode. I tried this:

    $zg_get_title = get_the_title($value+0);

    and this:

    echo "<a href=\"". get_permalink($value+0) . "\" title=\"". $zg_title_out->post_title . "\">". get_the_title($value+0) . "</a>\n";

    but both give a sql error so I am missing something about the loop. I would love to see if this can be done.

    Thanks!

    http://wordpress.org/extend/plugins/last-viewed-posts/

  2. energykick
    Member
    Posted 1 year ago #

    Now I have found some nice way to format my output with a photo and all like this:

    echo "<div style=\"width: 550px;\"> <div style=\"float: left; width: 100px;\">";
    echo "<img class=\"floatLeft\" src=".get_the_post_thumbnail( $post_id, array(100,100));echo "</div> <div style=\"float: left; padding-left: 10px; width: 430px;\">";
    echo "<a href=\"". get_permalink($value+0) . "\" title=\"". $zg_title_out->post_title  . "\">". $zg_title_out->post_title . "</a>\n";
    echo "</div>";
    echo "<br style=\"clear: left;\" /><hr>";

    but still cannot get the title to calculate my shortcode. I also tried this:
    $zg_get_title = do_shortcode('[exercisetitle]');

    but it also gives and error. Does anyone have ideas how this can be done.

    thanks!

  3. Noumaan Yaqoob
    Member
    Plugin Author

    Posted 1 year ago #

    Another neat way to do this is to find out the function used to add shortcode your will find function name in the add_shortcode line inside your functions.php or the plugin that generated the shortcode.

    add_action('exercisetitle', 'function_name');

    use that function like this

    $zg_get_title = function_name();

  4. energykick
    Member
    Posted 1 year ago #

    Oh, thank you for answering so quick. I understand some things but not how the title shortcode works. I just added this to function.php

    add_filter( 'the_title', 'do_shortcode' );

    and it works. Do you know if there is a way I can use your $zg_get_title to tie into that somehow.

    Thanks
    Rob

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.