0

i met a wordpress shortcode problem, below is the code that put in the functions.php file

function post_content_func($atts, $content = null) {

    extract(shortcode_atts(array(
        'name_one' => '',
        'name_two' => '',
        'name_three' => '',
        'name_four' => '',
        'name_five' => '',
        'name_six' => '',
        'name_seven' => '',
        'name_eight' => '',
        'name_nine' => '',
        'name_ten' => '',
        'name_eleven' => '',
        'name_twelve' => ''
    ), $atts));

    return '<div class="post_content_list"><ul class="post_list">
    <li><a href="#title1">1. ' . $name_one . '</a></li>
    <li><a href="#title2">2. ' . $name_two . '</a></li>
    <li><a href="#title3">3. ' . $name_three . '</a></li>
    <li><a href="#title4">4. ' . $name_four . '</a></li>
    <li><a href="#title5">5. ' . $name_five . '</a></li>
    <li><a href="#title6">6. ' . $name_six . '</a></li>
    <li><a href="#title7">7. ' . $name_seven . '</a></li>
    <li><a href="#title8">8. ' . $name_eight . '</a></li>
    <li><a href="#title9">9. ' . $name_nine . '</a></li>
    <li><a href="#title10">10. ' . $name_ten . '</a></li>   
    <li><a href="#title11">11. ' . $name_eleven . '</a></li>
    <li><a href="#title12">12. ' . $name_twelve . '</a></li>
    </ul></div>';

}

add_shortcode('post_tt', 'post_content_func');

and i put the below shortcode in my post,

[post_tt  name_one="buy domain"  name_two="buy hosting"  name_three="wordpress install" name_four="wordpress theme install"   name_five="build a homepage" name_six="build a category"  name_seven="build a contact page" name_eight="build about us page " name_nine="build faq page " name_ten="build inquiry page" name_eleven="build download page" name_twelve="website online"]

but it can not work.

So what is the cause? Thanks in advance!

  • 1
    I've tested your code and it works exactly as expected? What is not working on your end? Do you see the shortcode in the page? – Bjorn Jun 10 '18 at 7:34
  • Are you using the_content() in your template file? Do other shortcodes work? – janh Jun 10 '18 at 7:58
  • thank you @bjorm the code is fixed now. I tested the code in my xampp software and i don't know whey it is not working , but after i put the code on a online website, it does work, so the code is fine and the problem may be caused by xampp. – Hunk Song Jun 10 '18 at 8:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.