StudioPress Community Forums
  StudioPress Community Forums > Forums > General Discussion
For help and support, access to your downloads, or to manage your account please log into My StudioPress.

These forums have been set to read-only so you can browse the existing topics for any questions you may have.

For general discussion on WordPress, CSS and design (NOT for support) visit the new Community Forums.
 
 
Thread Tools Display Modes
  #1  
Old 11-10-2012, 12:16 AM
vbrasil vbrasil is offline
Registered User
Genesis Member
 
Join Date: Apr 2012
Posts: 8
Default how to add an action to a specific page or post but no all pages or posts?

I am creating a simple child theme for a site with a few pages.

On this child theme I am trying to implement the use of a plugin, skitter_slideshow. Its a slider plugin that is invoked when you add the following code to posts.php in wordpress:

<?php if ( function_exists('show_skitter') ) { show_skitter(); } ?>

On the Genesis Framework I have added the following code to my child theme's functions.php file:


if ( function_exists('show_skitter')) add_action( 'genesis_after_post_content', 'show_skitter');

This works and invokes the plugin slider. However, it does it for every post and page.

My objective is to just have it display on a particular page or post and not any of the other pages or posts in the site.

Any suggestions on how I can do that within the framework.
__________________
Vinicius Brasil
http://www.mountainviewrealestateguy.com
  #2  
Old 11-10-2012, 08:10 AM
NicktheGeek's Avatar
NicktheGeek NicktheGeek is offline
Forum Manager
 
Join Date: Feb 2010
Posts: 62,650
Default

You can make your code conditional
http://nickc.co/conditional-content
__________________
Nick "Fred and/or George Weasley" Croft
Designs by Nick the Geek
@Nick_theGeek on Twitter

Make web design easier, get FireBug for FireFox

Want to learn more about Genesis? Check out my Genesis Explained Series

  #3  
Old 11-11-2012, 01:03 AM
vbrasil vbrasil is offline
Registered User
Genesis Member
 
Join Date: Apr 2012
Posts: 8
Default

Thanks for the response Nick. I read the post, it seemed very clear and made sense to me. I was just testing the logic, perhaps my PHP is not correct, but I didn't work for me in my application. Can you please take a look at the code and let me know if I am doing anything wrong.

if (is_page() && is_category('photo')) {

if ( function_exists('show_skitter')) add_action( 'genesis_after_post_content', 'show_skitter');

}

My site http://www.missionplacehomes.com is just made up of several pages. One page I put under the category photo but it didn't work. To troubleshoot I then tried to simplify it to:

if (is_page() ) {

if ( function_exists('show_skitter')) add_action( 'genesis_after_post_content', 'show_skitter');

}

And this had no effect either. I am obviously doing something wrong, but its not obvious to me what it is. Please let me know if you know. Thanks
__________________
Vinicius Brasil
http://www.mountainviewrealestateguy.com
  #4  
Old 11-11-2012, 07:22 AM
NicktheGeek's Avatar
NicktheGeek NicktheGeek is offline
Forum Manager
 
Join Date: Feb 2010
Posts: 62,650
Default

this needs to be added differently. The is_page/is_category conditionals don't have anything to work with till after teh query is built.
PHP Code:
add_action'genesis_after_post_content''child_maybe_show_skitter');
function 
child_maybe_show_skitter() {
    if( 
is_page() && is_category('photo') )
        
show_skitter();

__________________
Nick "Fred and/or George Weasley" Croft
Designs by Nick the Geek
@Nick_theGeek on Twitter

Make web design easier, get FireBug for FireFox

Want to learn more about Genesis? Check out my Genesis Explained Series

  #5  
Old 11-13-2012, 01:12 AM
vbrasil vbrasil is offline
Registered User
Genesis Member
 
Join Date: Apr 2012
Posts: 8
Default

That worked perfectly, thanks Nick. I am currently reading your Genesis Framework Explained Series, very enlightening.

I am trying to do one more thing. I want to remove the author and date info after the post. I am trying to find the hook and function that it pertains to. My methodology is to look in the post.php file. And I thought I found it but I was wrong since my change did nothing.

what I added to my child functions.php file was:

remove_action( 'genesis_after_post_content', 'genesis_post_meta' );

I then created a post.php file and added the same action above, and no change.

Basically I looked for the action I thought added in the function and just removed it, but that didn't work. Do I have the right idea here?

I am having a difficult time finding this, any tips on how to locate these actions for future reference.
__________________
Vinicius Brasil
http://www.mountainviewrealestateguy.com
  #6  
Old 11-13-2012, 06:45 AM
NicktheGeek's Avatar
NicktheGeek NicktheGeek is offline
Forum Manager
 
Join Date: Feb 2010
Posts: 62,650
Default

looks right in theory, please start a new thread and we can help out. Thanks

You're welcome.

Since this is resolved I'm going to close this thread.
__________________
Nick "Fred and/or George Weasley" Croft
Designs by Nick the Geek
@Nick_theGeek on Twitter

Make web design easier, get FireBug for FireFox

Want to learn more about Genesis? Check out my Genesis Explained Series

 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 12:15 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.