Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Adding text to a function…

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #33617
    WildSpirit
    Member

    I am currently using the Genesis theme from StudioPress and really like it BUT am not very good at php so I have run into a little problem!
    Here is the page I’m working on: http://bosstin.wildspiritdesigns.com/category/bassandbait

    Before I made any changes, each product image linked to the post that went with it. What I wanted was for the image to just enlarge when clicked on. Figured that out (not sure if it’s the easiest solution but seems to be working!) but now I want to add a little piece of text under the image that says “Click Image to Enlarge”.

    Here is the current code I have. I was hoping Genesis had an easy way to do this but after asking around on their forums was told there was not. I was given the “add_action” code and got the “if (has_post_thumbnail)” to end for the WP Forums. If there is any other info needed let me know!

    function child_do_grid_loop() {

    global $query_string, $paged;

    // Ensure the arguments for the normal query for the page are carried forwards
    parse_str( $query_string, $query_args );

    // Create an array of arguments for the loop - can be grid-specific, or
    // normal query_posts() arguments to alter the loop
    $grid_args = array(
    'features' => 0,
    'feature_image_size' => 0,
    'feature_image_class' => 'alignleft post-image',
    'feature_content_limit' => 0,
    'grid_image_size' => '0',
    'grid_image_class' => 'alignleft post-image',
    'grid_content_limit' => 0,
    'more' => __( '', 'genesis' ),
    'posts_per_page' => 100
    );

    add_action( 'genesis_before_post_content', 'child_function_name' );
    function child_function_name() {
    if ( has_post_thumbnail()) {
    $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large');

    echo '';
    the_post_thumbnail('thumbnail');
    echo '

    Click Image to Enlarge

    ';
    echo '
    ';

    }

    }

    Do I need to some how add a div in there to style the “click to enlarge” text??
    Thanks,
    Lyle

    #83861
    stevendeeds
    Member

    Is it not echoing that paragraph with the ‘click image to enlarge’ text? I would probably make that part its own function, I definitely wouldn’t put it in the anchor tag like you have it, and you can style the paragraph however you want, just add a class to it..
    and remember, you have to call a function after you set it up for it to output anything..

    #83866
    WildSpirit
    Member

    It is echoing the “Click image to enlarge” text it’s just not under the images it’s to the right of the image above the description of the text… I really don’t know anything about functions, it’s a miracle that the one for the image thumbnail worked as I copied and pasted it in for where I found it in my searches!!

    #83922
    WildSpirit
    Member

    Still haven’t been able to figure this out. Not even sure really how to set up a function on my own. Is there a way it can be a function within this current one? Do the divs with class have to be echoed to make it work?

    #83910
    stevendeeds
    Member

    OH! well then you just need to style your element. Remember, php reads your code, and outputs as plain html! so, if you want to style the element, just make that p tag a p class=”click”..

    so like…

    echo '

    ' . 'Click Image To Enlarge' . '

    ';

    and then your css would be something like..

    .click {float: left; }
Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Back End’ is closed to new topics and replies.