开发者

formatting posts in wordpress

I'm developing a wordpress theme, but I'm stuck in formatting the single.php. I have in my posts a slideshow plugin which is load with the_content() function, togheter wi开发者_JAVA技巧th the text of the post, and with the_title() load the title.

that seen like this:

<h1>the_title()</h1>

<div id=post>the_content</div>

the problem is, I need customize how it's display.

I need display:

<div>theplugin</div>

<div id=post>

<span>the_title</span>

the text

</div>

I try to do that with add_filters but I wasn't lucky.

I hope you can understand my explanation, if you need more details, just tell me.

Thanks in advanced.


If users can add plugin components to posts in the editor, they are usually added via shortcodes.

If that's the case with your plugin, you can add it with apply_filters(). Here's an example of how to add a slideshow from the popular nextgen gallery plugin outside the post content:

<?php
    $slideshow = apply_filters('the_content', '[slideshow id=1]' );
    echo $slideshow;
?>

The above code can be added into single.php, any static page's page template file or directly into header.php to display on all pages. If you specify the plugin you're using, I'll update the answer accordingly.

If it should indeed be called directly via a function, I second Ancide's answer.


You just need to change the place of where the functions are situated. Like this:

<div>theplugin</div>
<div id=post>
    <span><?php the_title(); ?></span>
    <?php the_content(); ?> 
</div>

Edit: I misunderstood the description of the problem. Here's my answer now that I understand what the problem is:

The plugin uses a hook for the_content function. If you look inside all the php-files inside wp-content/plugins/your-plugin there will be a file with this code:

add_action('the_content','some-function-name');

This tells wordpress to run the function some-function-name everytime the function the_content is run. So you need to look for the some-function-name to figure out how to customize the output.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜