• Resolved irina76

    (@irina76)


    Hi. I’m trying to modify the source code of my theme but unfortunately my php-knowledge is too limited to get it right. Would really appreciate some help on hiding the post title.

    Here’s what it looks like before I add the shortcode:

    <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>

    Here’s what I’ve done:

    <?php echo do_shortcode('[CBC country="se" show="n"]'
    <h2><a href="'.the_permalink().'">'.the_title().'</a></h2> '[/CBC]'); ?>

    Result —> Parse error: syntax error, unexpected ‘>’

    What am I missing?

    http://ww.wp.xz.cn/extend/plugins/custom-content-by-country/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Paul

    (@paultgoodchild)

    Hi,

    The problem you have here are the functions you’re using to displaying the parts of the title, and some syntax. Try this instead:

    echo do_shortcode( '[CBC country="se" show="n"]<h2><a href="'.get_permalink().'">'.get_the_title().'</a></h2>[/CBC]');

    Let me know if that works for you.
    Cheers,
    Paul.

    Thread Starter irina76

    (@irina76)

    Thanks Paul. This:

    <?php echo do_shortcode('[CBC country="se" show="n"]<h2><a href="'.get_permalink().'">'.get_the_title().'</a></h2>[/CBC]'); ?>

    … gives me the following error:

    Parse error: syntax error, unexpected T_ENDWHILE…

    Actually it would be even better if there was some way to hide a category from certain countries. That way I could just assign posts to different categories and the front page would automatically display only the relevant posts for the country the visitor is coming from. Hope this explanation makes sense.. Maybe an idea for the next version of the plugin?

    Plugin Author Paul

    (@paultgoodchild)

    Hi,

    You’re wrapping up what I put in the last post with <?php and ?>

    Why? It depends on your PHP code if you need to do that. I can’t see any syntax error in my code, which would mean how you’re adding it to your code may be wrong.

    As for categories and things like that, that goes too far into the theme and display of content for this plugin. You’d need a multilingual plugin to handle what you’re looking to achieve.

    Cheers,
    Paul.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘A little do_shortcode() problem’ is closed to new replies.