Community Forums › Forums › Archived Forums › Design Tips and Tricks › Adding a custom 'After Entry' for a specific page
- This topic has 11 replies, 3 voices, and was last updated 9 years ago by Brad Dalton.
-
AuthorPosts
-
March 15, 2015 at 2:50 pm #144536alethamcmanamaMember
I want to be able to add a custom "after entry" widget on this page (see page below) instead of it taking the visitor back to the main blog archives page I set up, I want it to take the visitor to the testimonials page which is an archive of testimonial blog posts.
Single "Testimonials" post page:
http://srinikahealing.com/draft/my-skin-condition-gradually-went-away-within-two-months-k-h/I was hoping i could use the Simple Sidebar plugin to do this, but the bottom of the blog page is not considered a sidebar.
Thanks in advance for your help!
Warmly,
http://srinikahealing.com/draft/my-skin-condition-gradually-went-away-within-two-months-k-h/
Aletha McManamaMarch 15, 2015 at 6:28 pm #144553ChristophMemberAre you using a category for your testimonials?
You would have to use a conditional function, so that if the category is testimonial it links to the testimonial archive, and if it isn´t it links to the "regular" archive.
Something like:
function link_testimonial_blog_archive () { if ( is_category('name_or_id_of_your_category' ) ) { echo '<a href="link_to_your_testimonial_archive"><img src="link_to_your_image">Back to Testimonials</a>'; } else {*Whatever you have in your after entry widget now*} }; add_action( 'genesis_after_entry', 'link_testimonial_blog_archive' );
You can enter this in the simple hooks plugin at the genesis_after_entry Hook. Remember to check "Execute php on this hook?"
Or you can add it to the functions.php.If you are using the after entry widget area, make sure to delete its content.
For more on conditionals take a look here:
http://codex.wordpress.org/Conditional_Tags
March 24, 2015 at 7:23 am #145454alethamcmanamaMemberChristoph,
I attempted to add the above in the functions.php file, but I got an error message that read this:
Parse error: syntax error, unexpected '*' in /home/content/37/8755837/html/draft/wp-content/themes/enterprise-pro/functions.php on line 152
Maybe I placed it incorrectly in the functions.php file?
Below is what I pasted in the functions.php file based on what you said add in:
function link_testimonial_blog_archive () {
if ( is_category('testimonials' ) ) {
echo 'Back to Testimonials';
} else {*<p><span style="text-decoration: underline;">
Back to Blog Archives</span></p>*}
};add_action( 'genesis_after_entry', 'link_testimonial_blog_archive' );
Did I input something above incorrectly?
Help?
Thanks so much!
Warmly,
Aletha McManamaMarch 24, 2015 at 7:44 am #145458ChristophMemberHi Aletha,
just remove the *.
I should have clarified that I used them as placeholders.
*Whatever you have in your after entry widget now*
March 24, 2015 at 7:51 am #145460alethamcmanamaMemberChristoph,
I did actually remove those asterisks earlier, then saved, but still got the parse error above. Maybe I placed the code in the wrong place in the functions.php file? I had originally placed it at the bottom of the functions.php file, but then tried the middle and still got the error message. Any other ideas?
Thanks!
Aletha
March 24, 2015 at 8:08 am #145465ChristophMemberHi Aletha,
can you paste the code again using the code tags?
It´s the second from the right on top of this editor.
One before the code and one after.
Otherwise the code gets formatted and it´s hard to tell if there is something wrong with it.
March 24, 2015 at 8:13 am #145468alethamcmanamaMemberfunction link_testimonial_blog_archive () { if ( is_category('testimonials' ) ) { echo '<a href="http://srinikahealing.com/draft/testimonials/"><img src="http://srinikahealing.com/draft/wp-content/uploads/2015/01/back-arrow-burg_25x25px.png">Back to Testimonials</a>'; } else {*<p><span style="text-decoration: underline;"><strong><a title="Blog" href="http://srinikahealing.com/draft/blog-summary/"> <img class="alignleft size-full wp-image-2603" src="http://srinikahealing.com/draft/wp-content/uploads/2015/01/back-arrow-burg_25x25px.png" alt="back-arrow-burg_25x25px" width="25" height="25" border="0" />Back to Blog Archives</a></strong></span></p>*} }; add_action( 'genesis_after_entry', 'link_testimonial_blog_archive' );
March 24, 2015 at 8:58 am #145472ChristophMemberHi,
this should work now:
function link_testimonial_blog_archive () { if ( in_category('testimonials') ) { echo '<a href="http://srinikahealing.com/draft/testimonials/"><img src="http://srinikahealing.com/draft/wp-content/uploads/2015/01/back-arrow-burg_25x25px.png"><p><span style="text-decoration: underline;"><strong>Back to Testimonials</strong></span></p></a>'; } else { echo '<a href="http://srinikahealing.com/draft/blog-summary/"><img class="alignleft size-full wp-image-2603" src="http://srinikahealing.com/draft/wp-content/uploads/2015/01/back-arrow-burg_25x25px.png" alt="back-arrow-burg_25x25px" width="25" height="25" border="0" /><p><span style="text-decoration: underline;"><strong>Back to Blog Archives</strong></span></p></a>';} }; add_action( 'genesis_after_entry', 'link_testimonial_blog_archive' );
I liked it better to place the links above the comments. That would be this action hook instead:
add_action( 'genesis_entry_footer', 'link_testimonial_blog_archive' );
March 24, 2015 at 9:19 am #145475alethamcmanamaMemberAwesome, Christoph. That really worked! And, yes, I like the links to be placed above the comments, so I went with the action hook above.
One more question though and then I'm done:
Is there any way to not have the "blog archives" image and link not show up on this page (link below) where I have a layout view of just one blog post and I have a link to go to the blog archives page already? I don't need it to show up twice, plus for some reason, my arrow image is squashed down to where you can't even see it at the bottom of that page.
Here's the page I'm referring to: http://srinikahealing.com/draft/blog/
You've been SO helpful in me resolving this issue. I cannot WAIT to get this website completed!
Warmly,
AlethaMarch 24, 2015 at 10:51 am #145482ChristophMemberLet me know if this works:
function link_testimonial_blog_archive () { if ( is_single && in_category('testimonials') ) { echo '<a href="http://srinikahealing.com/draft/testimonials/"><img src="http://srinikahealing.com/draft/wp-content/uploads/2015/01/back-arrow-burg_25x25px.png" /><p><span style="text-decoration: underline;"><strong>Back to Testimonials</strong></span></p></a>'; } elseif ( is_single() ) { echo '<a href="http://srinikahealing.com/draft/blog-summary/"><img src="http://srinikahealing.com/draft/wp-content/uploads/2015/01/back-arrow-burg_25x25px.png" alt="back-arrow-burg_25x25px" width="25" height="25" border="0" /><p><span style="text-decoration: underline;"><strong>Back to Blog Archives</strong></span></p></a>';} else { echo '' ;} }; add_action( 'genesis_entry_footer', 'link_testimonial_blog_archive' );
March 24, 2015 at 11:13 am #145493alethamcmanamaMemberThat did the trick this time, Christoph. Again, thank you for all your time in helping me resolve this. I've learned something new about the Genesis themes today!
Warmly,
AlethaMarch 24, 2015 at 6:59 pm #145565Brad DaltonParticipant -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.