Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Adding a Do Shortcode via a Custom Field WordPress

Hi guys,

Looking for a suggestion to a problem I am having.

I have a theme, that has some broken jQuery on it. The broken jQuery means that I cannot Embed a Gravity Form using a template tag, into the php file.

I can insert a form using the standard [shortcode] into the post, which works, but i cannot position this where i want to.
Can any answer and give me the code if possible to do the following:

<?php echo do_shortcode('[shortcode]')<?php echo get_post_meta($post->ID, 'domain_register_form', true); ?>; ?>


It looks a mess but essentially I want to have a Do Shortcode, get shortcode as a custom field.

Any ideas?

Failing that can anyone fix the jQuery issues here: http://bit.ly/qTIsxh

Answers (5)

2011-07-18

Utkarsh Kukreti answers:

What exactly does your custom field 'domain_register_form' contain? Gravity form id?


Justin Walmsley comments:

Yeah just trying to add the Gravity Form, form specific, Shortcode:

[gravityform id=1 name=DomainRegistration Form title=false]

I have added the form (using the shortcode) to the post text area so you can see the form working.

2011-07-18

Jurre Hanema answers:

Shouldn't be too hard:


<?php
$shortcode = get_post_meta($post->ID, 'domain_register_form', true);

echo do_shortcode($shortcode);
?>


Justin Walmsley comments:

Didn't work :(

2011-07-18

Gabriel Reguly answers:

Hi,

Why not use Google's jQuery?

http://wordpress.org/extend/plugins/use-google-libraries/

Regards,
Gabriel


Justin Walmsley comments:

I tried doing that earlier! Great minds think a like.

But it wouldn't call the scripts :(

I only really know HTML, CSS a tiny bit of PHP and making minor adjustments to WordPress Templates

2011-07-18

Romel Apuya answers:

have you tried this?


<?php echo do_shortcode('[shortcode]').get_post_meta($post->ID, 'domain_register_form', true);?>


Romel Apuya comments:

hi,

try this

<?php echo do_shortcode('["name_of_post_type","domain_register_form" ]'); ?>

where name_of_post_type is the name of your post type
and domain_register_form is the name of the custom field.

2011-07-21

Geraint Palmer answers:

a good place to start to look for you jquery problems is the 404 from these includes.

wp-whois.js Failed to load resource: the server responded with a status of 404 (Not Found)
swstyles.css Failed to load resource: the server responded with a status of 404 (Not Found)

not the css file, but if a function in the missing wp-whois.js is called it would probably kill the jquery process dead, so either disable that plugin, or find out where its missing js file is, should probably fix it.