Tagged: child theme, contact form 7, portfolio items
-
AuthorPosts
-
August 30, 2018 at 11:19 pm #1003828
HI
I was trying to add a form from Content Form 7 to the bottom of all my portfolio items.
I found this post: https://kriesi.at/support/topic/how-to-re-use-contact-form-at-the-portfolio-entry/#post-318532
and so added this code to my child theme php:add_filter( ‘the_content’, ‘my_the_content_filter’, 20 );
function my_the_content_filter( $content ) {
if ( is_singular(‘portfolio’) )
$content .= do_shortcode(“[contact-form-7 id=’23147′ ‘title=”test 2’]”);
return $content;
}that worked fine, I thought, and was displaying under my content on the portfolios, but it seemed a little unstable when it was loading, and then I saw it was also displaying under every textblock in the Itinerary section as well – see: https://imgur.com/a/rq8uNpY. I took the code off until I could find out how to fix that, and something got corrupted in my site, which I had to fix by restoring the site to a backup (and losing work).
Can you see what’s wrong? Did something get corrupted? I didn’t change any styling settings, and have commented out the code I added. I also have some code in the child theme that is displaying portfolio tags on every portfolio item at the bottom of the page. I would ultimately like a contact form under the tags.
thanks for your help
Nancy- This topic was modified 6 years, 3 months ago by Munford.
September 1, 2018 at 10:52 am #1004301Hey Munford,
If you’re using tabs, etc. you can’t use this code because the “the_content” filter is also applied to other elements (i.e. tabs) and not only to the portfolio main content/text.
I now added this code to your child theme functions.php (at the very bottom)
/* Add Contact form 7 to all portfolio entries */ add_filter('avf_template_builder_content', 'avia_add_contact_form_seven_to_portfolio', 1000, 1); function avia_add_contact_form_seven_to_portfolio($content) { if(is_singular('portfolio')) { $content .= do_shortcode('[contact-form-7 id="23147" title="test 2"]'); } return $content; }
to show display the contact form. If yo want to display it above the tags replace 1000 with a lower value (i.e. 900).
Best regards,
DudeSeptember 1, 2018 at 2:15 pm #1004369Hi Dude
Yes I just saw that – looks great – thanks!
can I ask you another question?
Is is possible to exclude certain pages from showing that form?
There are a few where we need a different one.best
Nancy- This reply was modified 6 years, 3 months ago by Munford.
September 1, 2018 at 3:02 pm #1004384Hi,
Yes use this code instead:
/* Add Contact form 7 to all portfolio entries */ add_filter('avf_template_builder_content', 'avia_add_contact_form_seven_to_portfolio', 1000, 1); function avia_add_contact_form_seven_to_portfolio($content) { if( is_singular('portfolio') && ! is_single(array(1,2,3,4)) ) { $content .= do_shortcode('[contact-form-7 id="23147" title="test 2"]'); } return $content; }
and replace 1,2,3,4 with the portfolio entry ids where you DON’T want to show the contact form. Separate multiple ids with commas.
Best regards,
DudeSeptember 1, 2018 at 3:19 pm #1004388thanks I will try that – sound easy enough
one related question:
Is there a way to add a button shortcode to the top of every portfolio page as well?
something like this:
[av_button label='BOOK HERE' link='manually,#bookhere' link_target='' size='large' position='right' label_display='' icon_select='no' icon='ue800' font='entypo-fontello' color='dark' custom_bg='#444444' custom_font='#ffffff' av_uid='av-14vrx59' custom_class='' admin_preview_bg='']cheers!
Nancy- This reply was modified 6 years, 3 months ago by Munford.
September 1, 2018 at 3:27 pm #1004392Hi!
Yes, I’ll leave the thread open :)
Cheers!
PeterSeptember 1, 2018 at 3:33 pm #1004395I updated my comment above
September 1, 2018 at 3:40 pm #1004396Hi,
Yes with some code like:
add_filter('avf_template_builder_content', 'avia_add_contact_form_seven_to_portfolio', 10, 1); function avia_add_contact_form_seven_to_portfolio($content) { if( is_singular('portfolio') ) { $content = do_shortcode("[av_button label='BOOK HERE' link='manually,#bookhere' link_target='' size='large' position='right' label_display='' icon_select='no' icon='ue800' font='entypo-fontello' color='dark' custom_bg='#444444' custom_font='#ffffff' av_uid='av-14vrx59' custom_class='' admin_preview_bg='']") . $content; } return $content; }
Best regards,
DudeSeptember 1, 2018 at 3:55 pm #1004400that’s great I will check it out!
UPDATE: I don’t need the button code anymore as I can do it better with a widget in the sidebar :)
but I was getting this:
Your PHP code changes were rolled back due to an error on line 265 of file wp-content/themes/enfold-child/functions.php. Please fix and try saving again.Cannot redeclare avia_add_contact_form_seven_to_portfolio() (previously declared in wp-content/themes/enfold-child/functions.php:246)
- This reply was modified 6 years, 3 months ago by Munford.
September 1, 2018 at 6:59 pm #1004447what if I wanted to add something like this to the bottom of each portfolio item, instead of just the contact form:
[av_one_full first min_height='' vertical_alignment='av-align-top' space='' margin='0px' margin_sync='true' link='' linktarget='' link_hover='' padding='10px,30px,10px,30px' border='1' border_color='#b5b5b5' radius='2px' radius_sync='true' background='bg_color' background_color='#efefef' background_gradient_color1='' background_gradient_color2='' background_gradient_direction='vertical' src='' attachment='' attachment_size='' background_position='top left' background_repeat='no-repeat' animation='' mobile_breaking='' mobile_display='' av_uid='av-4vhgskt' custom_class='']
[av_codeblock wrapper_element='' wrapper_element_attributes='' codeblock_type='' av_uid='av-jlj9mkgt' custom_class='']
<span id = “bookhere”></span>
[/av_codeblock][av_hr class='invisible' height='30' shadow='no-shadow' position='center' custom_border='av-border-thin' custom_width='50px' custom_border_color='' custom_margin_top='30px' custom_margin_bottom='30px' icon_select='yes' custom_icon_color='' icon='ue808' font='entypo-fontello' av_uid='av-2x8wuel' custom_class='' admin_preview_bg='']
[av_textblock size='' font_color='' color='' av-medium-font-size='' av-small-font-size='' av-mini-font-size='' av_uid='av-48n4vu5' custom_class='' admin_preview_bg='']
<h2>BOOKING FORM – REQUEST PRICE</h2>
[/av_textblock][av_textblock size='' font_color='' color='' av-medium-font-size='' av-small-font-size='' av-mini-font-size='' av_uid='av-3n3s2q5' custom_class='' admin_preview_bg='']
[contact-form-7 id=”23464″ title=”fixed-form-arg-01″]
[/av_textblock][av_hr class='invisible' height='20' shadow='no-shadow' position='center' custom_border='av-border-thin' custom_width='50px' custom_border_color='' custom_margin_top='30px' custom_margin_bottom='30px' icon_select='yes' custom_icon_color='' icon='ue808' font='entypo-fontello' av_uid='av-2x8wuel' custom_class='' admin_preview_bg='']
[/av_one_full][av_hr class='invisible' height='20' shadow='no-shadow' position='center' custom_border='av-border-thin' custom_width='50px' custom_border_color='' custom_margin_top='30px' custom_margin_bottom='30px' icon_select='yes' custom_icon_color='' icon='ue808' font='entypo-fontello' av_uid='av-2x8wuel' custom_class='' admin_preview_bg='']
Is that possible? If I put it in that shortcode area you gave me for the contact form only, I get php errors.
thanks
Nancy- This reply was modified 6 years, 3 months ago by Munford.
September 1, 2018 at 7:13 pm #1004449update –
I figured another way to do the buttton, so I don’t need to use that code!
I would still like a way to add the extra code above as a contact form at the bottom of the portfolio items, if possible.
thanks
Nancy- This reply was modified 6 years, 3 months ago by Munford.
September 2, 2018 at 11:04 am #1004603Hi Again
Is it possible to just add this or something like it to the bottom of the portfolio items to also add a custom class id above the contact form:
[av_codeblock wrapper_element='' wrapper_element_attributes='' codeblock_type='' av_uid='av-jlj9mkgt' custom_class=''] <span id = “bookhere”></span> [/av_codeblock] [contact-form-7 id=”23464″ title=”fixed-form-arg-01″]
I am getting an error in the wrapper elements:
Your PHP code changes were rolled back due to an error on line 165 of file wp-content/themes/enfold-child/functions.php. Please fix and try saving again.
syntax error, unexpected ” wrapper_element_attributes=” (T_CONSTANT_ENCAPSED_STRING), expecting ‘,’ or ‘)’
or maybe there is a way to incorporate the class ID into the contact form itself?
thanks for your help!
NancySeptember 2, 2018 at 8:19 pm #1004698Hi,
How are you adding the code, where do you place it?
Best regards,
BasilisSeptember 3, 2018 at 10:40 am #1004841I am putting it in my child theme functions.php but I think I may not need this after all as I found a way to do it in the sidebar.
Would like to know if it’s possible though.
thanks for your help
NancySeptember 3, 2018 at 9:25 pm #1005162Hi,
Placing on the child theme functions.php file is the best solution yes.
Best regards,
BasilisOctober 8, 2018 at 4:20 pm #1019034you can close this thread
thanksOctober 8, 2018 at 7:02 pm #1019132Hi,
I’m glad this was resolved. If you need additional help, please let us know here in the forums.
Best regards,
Jordan Shannon -
AuthorPosts
- The topic ‘add content form to the bottom of all portfolio items’ is closed to new replies.