I would like some advice on the following issue:
What would be the best way to edit a page that has 2x columns via the editor?
You can try it with the Custom Field Template.
For the first column you can use the default editor of Wordpress and for the second you can create a custom field in which the plugin shows a textarea with TinyMCE support.
Posible code for the "custom field template" to show a textarea in a custom field area:
[column_2]
type = textarea
rows = 4
cols = 40
tinyMCE = true
htmlEditor = true
mediaButton = true
(you have to enter that code in wp-admin panel of the plugin).
To get the data from the custom field in your the template-file you can use the
get_post_custom_values function:
//returns an array
$colum_2_content = get_post_custom_values("column_2", $post_id);
echo $colum_2_content [0];
Related
I have a $_SESSION array variable with post ids. Inside foreach loop, I would like to get the posts titles of these ids. Thus so far I have something like this:
sport_title = '';
foreach($_SESSION['sports_post_id'] as $sports_id {
$sport_title = get_the_title($sport_id);
$sports_titles .= $sport_title . "<br />";
}
Now, my problem is that I do not know how to pass it in a custom variable in Contact Form 7 - Dynamic Text Extension plugin.
I have inside my form this field (inside CF7):
[dynamichidden dynamic_sports readonly default:shortcode_attr]
and inside my custom page template php file:
echo do_shortcode('[contact-form-7 id="3561" "CF7_get_custom_field dynamic_sports=\'$sports_titles\'" title="Availability Form EN"]');
Thus, I would like to send these post titles in email.. How can I make it work? thanks in advance
ok I figure it out how to do it! If anyone wants more explanation:
Inside Contact Form 7 - Form tab, I have insert this code:
[dynamichidden dynamic_sports "CF7_GET key='sports_post_id'"]
where key is a standard word (could not change it).
Inside Email tab, you should have this code:
Sports: [dynamic_sports]
Now, inside my Custom template PHP file, I have this shortcode:
echo do_shortcode('[contact-form-7 id="3561" title="Availability Form EN"]');
I also have a form with a hidden input type, with a name sports_post_id and value the id of the current post:
<input type="hidden" value="<?php echo get_the_title( get_the_ID() ); ?>" name="sports_post_id" id="sports_post_id" />
EDITED
Another solution via plugin that extends the CF7, would be the following:
Install Contact Form 7 - Dynamic Text Extension
Copy and paste the form-tag code below and then add it inside the form code block
[dynamichidden page-title "CF7_get_post_var key='title'"]
The above code will add a hidden text input to the form which will pre-populate the page title. This is good to use when you are using the same contact form on multiple pages so you know where the user has submitted the form from. Alternatively, you can display the page URL or slug using one of the below shortcodes instead:
[dynamichidden page-url "CF7_bloginfo show='url'"]
[dynamichidden page-slug "CF7_bloginfo show='url'"]
Displaying the Hidden Dynamic Content Tag Variable in Contact Form 7
Finally, display the hidden dynamic content tag variable in Contact Form 7 form. While you are on the CF7 settings page, click on the "Email" tab and insert this:
[page-title]
If you are using the URL or Slug fields, you these instead:
[page-url]
[page-slug]
In your CF7 Form configuration > Email Tab, you only have to add the desired field between hooks [...]
[dynamic_sports]
This will print the dynamic field value in your email.
I've got a Typerocket form (within Wordpress) and I'm trying to make a conditional field.
Like if the Type field is Image, show and Image field afterwards and if the Type field is Quote have a text (editor) field afterwards.
I can't find anything about Conditional fields in Typerocket's doc.
Here's what I got right now.
echo $form->repeater('pj_images_du_projet')->setLabel("Images du projet")->setFields([
$form->select('Type')->setOptions([
"Image"=>'image',
"Vidéo"=>'video',
"Témoignage"=>'temoignage'
]), //Type is what chooses what fields are below. Options are Image, Video or Testimonial
$form->image('image')->setLabel('Image'), //image only
$form->text('video')->setLabel('Vidéo'), //video only
$form->toggle('autoplay')->setLabel('Autoplay'), //video only
$form->textarea('temoignage')->setLabel('Témoignage'), //temoignage only
$form->text('auteur')->setLabel('Auteur'), //temoignage only
]);
Created a JS that does the work.
JS
jQuery('body').ready(function(){
jQuery("body").on('change','.is-conditional-selector',function(){px_redoConditionals();})
px_redoConditionals();
})
function px_redoConditionals(){
jQuery('body').find('.is-conditional-selector').each(function(){
var repeater = jQuery(this).parent().parent().parent();
console.log(repeater.attr('class'));
repeater.find('.is-conditional').removeClass('px-show');
//console.log(jQuery(this).val());
repeater.find('.is-conditional.is-conditional-'+jQuery(this).val()).addClass('px-show');
})
}
CSS
.is-conditional:not(.px-show){
display:none !important;
}
And then I add this to the select that changes which section is shown
->setAttribute('class','is-conditional-selector')
And this on the fields that need to be shown or hidden
->setAttribute('class','is-conditional is-conditional-[value of the select to show this]'),
I have a requirement where I wish to show a field office_name in WordPress default registration form.
What I did so far: I have created a field called 'office_name' by using the following code:
function my_show_extra_profile_fields() {
$user_contact_method['office_name'] = 'name of your office';
$user_contact_method['office_location'] = 'location of your office';
return $user_contact_method;
}
add_filter( 'user_contactmethods', 'my_show_extra_profile_fields' );
The office_name field is appearing in the USERS tab in the back end and getting updated when I enter the values there.
I want it to appear in the registration form.
You need to customize your registration form . Here is the Wordpress codex link.
https://codex.wordpress.org/Customizing_the_Registration_Form
I am currently using the following filter to replace any instance of the string 'magic_click_link' within WordPress' the_content.
function click_link ($b) {
global $post;
$this_post_id = $post->ID;
$op_name = get_field('operator_name');
$namenospace = make_no_space("$op_name");
$tracking_link = '/go/'.$this_post_id.'/';
$click_link = '<a class="claimCTA" id="operator-step1-'.$namenospace.'" href="'.$tracking_link.'" target="_blank" rel="nofollow">Click here to go to '.$op_name.'!</a>';
$b = str_ireplace('magic_click_link',$click_link,$b);
return $b;
}
add_filter( 'the_content', 'click_link');
I have just updated this field to use an ACF WYSIWYG field, but this has caused the filter to stop working.
I believe I need to target something other than the_content inside the filter but I'm not sure what is needed...
The filter the_content automatically runs on any content output using the function the_content(), so by default, this means it only applies to standard WordPress post and page content.
To apply these filters to your custom field content as well, you need to manually call apply_filters() when you output the field's content.
For example, say your custom field is called my_extra_content. With Advanced Custom Fields, you can call:
echo apply_filters("the_content", get_field("my_extra_content"));
This will output the content of your field, while applying all the usual filters against it. Because your click_link() function is hooked to the_content already, it will therefore process your custom field content as you are desiring.
I am looking for a wordpress plugin that will allow me to add a paragraph to the sidebar that is specific to the blog post. I would need to be able to add that text when creating the post. Is there something out there like that? I have been unsuccessful in searches.
Thanks
This can be easily solved using Custom Fields, the Text Widget and a Shortcode.
This bit of code goes in the theme's functions.php or, preferable, within a custom plugin.
1) Enable shortcodes for the Text Widget
add_filter( 'widget_text', 'do_shortcode' );
2) Define the shortcode, read comments for details
add_shortcode( 'mytext', 'so_13735174_custom_text_widget' );
function so_13735174_custom_text_widget( $atts, $content = null )
{
global $post;
// $post contains lots of info
// Using $post->ID many more can be retrieved
// Here, we are getting the Custom Field named "text"
$html = get_post_meta( $post->ID, 'text', true );
// Custom Field not set or empty, print nothing
if( !isset( $html ) || '' == $html )
return '';
// Print Custom Field
return $html;
}
3) Add a Text Widget in the desired sidebar.
Leave the title empty and put the Shortcode in the content: [mytext].
4) Now each page or post with a Custom Field named text will have its value printed in the Widget.
5) The $html can get fancy and multiple Custom Fields can be used.
This isn't something that I've ever personally done, but try this.
Summary: You will add the a paragraph using a custom field, then display it in a widget.
Details:
First, make sure custom fields are enabled. Edit a post, then click
the "screen options" at the top right of the page. If "Custom
Fields" isn't checked, check it. You should now see a custom field
area below the post editor.
Come up with a name for your custom field. Perhaps
"extra_paragraph". Now put that in the "name" field in the custom
field area.
Write your paragraph in the "value" field the custom field area.
Install the Custom Field Widget plugin, set it to display this
new "extra_paragraph" field. (widget appears to be untested with newer versions of Wordpress so cross your fingers!)
Now when you write or edit posts you should see this "extra_paragraph" field as an option in the "name" dropdown.