Forums

Which tag to use for Post Rendering of a Page? (3 posts)

  1. MaTiZzz
    Member
    Posted 1 year ago #

    Hello,

    I would like to register a post rendering hook for a WordPress Page that adds a class field to a img. It works for blog post, but it fails for Pages...

    The function is registered using
    add_filter('the_content','iprotectImages',99,1);

    Which tag do I need to use to target the <div class="content"> in the code below?

    <div class="container clear">
            <div class="content">
                <div id="show">
                    <img width="785" height="533" src="http://www.biomatt.nl/wp-content/uploads/2011/01/1171.jpg" class="attachment-full" alt="117" title="117" />            </div>
    
            </div>
            <div class="l_col">
                <div class="post_portfolio">
                    <h2>Koppen</h2>
                    <p class="post_divider">&mdash;</p>
                    <div class="post_text"><script langauge="javascript">alert("");</script><script langauge="javascript">alert("Hello World!");</script></div>
                </div>
    
            </div>
        </div>

    Thanks!

  2. christopherross
    Member
    Posted 1 year ago #

    <div class="content"> is most likely stored in your page.php file, outside the_content()

  3. MaTiZzz
    Member
    Posted 1 year ago #

    Thanks. This brought me one step further to a solution.
    The content I would like to target is generated in a theme specific php file (single-portfolio.php) shown here:

    <div class="container clear">
            <div class="content">
                <div id="show">
                    <?php
                        $args = array(
                            'post_type' => 'attachment',
                            'orderby' => 'menu_order',
                            'order' => ASC,
                            'numberposts' => -1,
                            'post_status' => null,
                            'post_parent' => $post->ID,
                            'exclude' => get_post_thumbnail_id()
                        );
                        $attachments = get_posts($args);
                        if ( $attachments ):
                            foreach ( $attachments as $attachment ):
                                echo wp_get_attachment_image($attachment->ID, 'full');
                            endforeach;
                        endif;
                    ?>
                </div>
            </div>

    Is there a tag so I can target images in an attachment with a post rendering hook?

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic