I've try to render an image inside the form but still doesnt render anything
Here's custom module
$image_options = array(
'path' => 'http://novelplanet.com/Content/images/noImage.jpg',
'alt' => 'Test alt',
'title' => 'Test title',
'width' => '50%',
'height' => '50%',
'attributes' => array('class' => 'image', 'id' => 'my-img'),
);
$image = theme('image', $image_options);
$form['y']['image_div'] = array(
'#prefix' => '<div class="image">',
'#suffix' => '</div>',
'#markup' => $image,
);
in my tpl
<?php print drupal_render($form['y']['image_div']); ?>
How do I render image inside the form.inc drupal 6
Use the theme method as follows:
theme('image', $path, $alt = '', $title = '', $attributes = NULL,
$getsize = TRUE);
you can also use
theme('imagecache', $presetname, $path, $alt = '', $title = '',
$attributes = NULL, $getsize = TRUE);
if you use the ImageCache module.
Related
I created a custom field with 'domain_url' id to add field in my taxonomy using the following code:
acf_add_local_field_group(array(
'key' => 'group_6294fa89c564b',
'title' => 'Domain url Field',
'fields' => array(
array(
'key' => 'field_629504c3cdd67',
'label' => 'domain url',
'name' => 'domain_url',
'type' => 'text',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'maxlength' => '',
),
),
'location' => array(
array(
array(
'param' => 'taxonomy',
'operator' => '==',
'value' => 'news_source',
),
),
),
));
And I want to get the value inside the categories foreach, I tried this code but it didn't give a result
<?php
$args = array(
'taxonomy' => 'news_source',
);
$cats = get_categories($args);
foreach($cats as $cat) {
?>
Name: <?php echo $cat->name; ?> >
Domain: <?php echo get_field('domain_url' ); ?> <br/>
<?php
}
?>
Is the problem in the code? Or does the extension not support it?
You are missing an argument in your get_field(). You need to add an arg for the term or term object.
<?php
$args = array(
'taxonomy' => 'news_source',
);
$cats = get_categories($args);
foreach($cats as $cat) {
?>
Name: <?php echo $cat->name; ?> >
Domain: <?php echo get_field('domain_url', $cat ); ?> <br/> // Put the term in here.
<?php
}
?>
In this case you may need an extra query, or to use the term string plus the term ID in a string.
This ACF documentation article shows some different methods of retrieving tax term fields as well.
I am developing a custom Divi module and I have a problem with the fb_support my module loads and works perfectly except in the visual editor. When I put the variable $this->fb_support = true my module disappear in visual editor and get this JavaScript error.
bundle.js?ver=3.0.106:formatted:1422 Uncaught TypeError: Cannot read property 'lockedParent' of undefined
at A (bundle.js?ver=3.0.106:formatted:1422)
at Object.ID_2 (bundle.js?ver=3.0.106:formatted:3571)
at e._invokeCallback (bundle.js?ver=3.0.106:formatted:35300)
at e.dispatch (bundle.js?ver=3.0.106:formatted:35288)
at Object.moduleActive (bundle.js?ver=3.0.106:formatted:7203)
at t.value (bundle.js?ver=3.0.106:formatted:8759)
at Object.l (bundle.js?ver=3.0.106:formatted:24713)
at Object.invokeGuardedCallback (bundle.js?ver=3.0.106:formatted:28497)
at Object.invokeGuardedCallbackAndCatchFirstError (bundle.js?ver=3.0.106:formatted:28500)
at h (bundle.js?ver=3.0.106:formatted:24781)
I think this error is because i donĀ“t have registered my plugin in JavaScript part. Exist any method to do this? Is the correct way to do this?
Here is the code of my plugin:
class Price_Manager extends ET_Builder_Module
{
function init ()
{
$this->name = 'Price Manager;
$this->slug = 'et_pb_prices';
$this->fb_support = true;
$this->whitelisted_fields = array(
'widget_title',
'widget_type',
'admin_label',
'module_id',
'module_class',
);
$this->main_css_element = '%%order_class%%';
$this->advanced_options = array(
'custom_margin_padding' => array(
'css' => array(
'important' => 'all',
),
),
'filters' => array(),
);
}
function get_fields ()
{
$fields = array(
'widget_title' => array(
'label' => 'Title',
'type' => 'text',
'option_category' => 'basic_option',
'description' => 'This is your widget title',
),
'widget_type' => array(
'label' => 'Type of Widget',
'type' => 'select',
'option_category' => 'basic_option',
'options' => array(
'company' => 'Company',
'residential' => 'Residential'
),
'description' => 'Here you can choose the type of widget.',
),
'admin_label' => array(
'label' => 'Admin Label',
'type' => 'text',
'description' => 'This will change the label of the module in the builder for easy identification.',
),
'module_id' => array(
'label' => 'CSS ID',
'type' => 'text',
'option_category' => 'configuration',
'tab_slug' => 'custom_css',
'option_class' => 'et_pb_custom_css_regular',
),
'module_class' => array(
'label' => 'CSS Class',
'type' => 'text',
'option_category' => 'configuration',
'tab_slug' => 'custom_css',
'option_class' => 'et_pb_custom_css_regular',
),
);
return $fields;
}
function shortcode_callback ($atts, $content = null, $function_name)
{
$module_id = $this->shortcode_atts['module_id'];
$module_class = $this->shortcode_atts['module_class'];
$widget_title = $this->shortcode_atts['widget_title'];
$widget_type = $this->shortcode_atts['widget_type'];
$module_class = ET_Builder_Element::add_module_order_class($module_class, $function_name);
$module_id = '' !== $module_id ? sprintf('id="%s"', esc_attr($module_id)) : '';
$module_class = '' !== $module_class ? sprintf('%s', esc_attr($module_class)) : '';
$content = 'My title: ' . $widget_title; // TODO: Fetch the item from DB and prepare HTML for output.
$content .= '<br />';
$content .= 'My type of widget: ' . $widget_type;
$output = sprintf(
'<div class="et_pb_prices_module_wrapper et_pb_module">
<div %1$s class="et_pb_prices%2$s et_pb_module">%3$s</div>
</div>',
$module_id,
$module_class,
$content
);
return $output;
}
}
new Price_Manager();
Thanks.
I want to display multiple image coming from meta box image.It display 'Array' as a result. I want to show images insted of 'Array.'
Meta box image code in function.php file:
add_filter( 'rwmb_meta_boxes', 'YOURPREFIX_register_meta_boxes' );
function YOURPREFIX_register_meta_boxes( $meta_boxes ) {
$prefix = 'rw_';
$meta_boxes[] = array(
'id' => 'personal3',
'title' => __( 'Image', 'textdomain' ),
'post_types' => array( 'post', 'page' ),
'fields' => array(
array(
'name' => __( 'Photo', 'textdomain' ),
'id' => $prefix . 'Photo',
'type' => 'image',
'force_delete' => false,
// Maximum image uploads
'max_file_uploads' => 4,
// Display the "Uploaded 1/2 files" status
'max_status' => true,
),
)
);
return $meta_boxes; }
Display code in loop.php file:
<?php
echo $myvar = rwmb_meta( 'rw_Photo');
?>
array of images
add below foreach loop in your loop
<?php
$myvar_array = rwmb_meta( 'rw_Photo');
foreach ( $myvar_array as $myvar_value )
{
//$myvar_value['url']
?>
<img src="<?php echo $myvar_value['url']; ?>" />
<?php
}
?>
Good day, I am creating a plugin that will automatically posts a slideshow article with page break using <!--nextpage--> , my problem is i want to custom the pagination style instead of page: 1,2 i want to show up as next-page and previous-page. how can i achieved this one? i want to put the code inside the plugin i don't want to add codes in the theme.
I have already tried adding this code in my plugin but did not work:
$defaults = array(
'before' => '<h1>' . __( 'Pages:' ),
'after' => '</h1>',
'link_before' => '',
'link_after' => '',
'next_or_number' => 'next',
'separator' => ' ',
'nextpagelink' => __( 'Next page' ),
'previouspagelink' => __( 'Previous page' ),
'pagelink' => 'Page %',
'echo' => 1
);
wp_link_pages( $defaults );
This is the code in my plugin:
$x = "";
foreach ($leadamajig_data->questions as $post)
{
$lead_title = '<p><h1 id="title">' . $post->title . '</a></h1></p>';
$lead_choices = '<p><h1 id="clicked"><a hre="#">' . $post->choices->a . '</a></h1></p>';
$lead_choices2 ='<p><h1 id="clicked2"><a hre="#">' .$post->choices->b . '</a></h1></p>';
$lead_choices3 = '<p><h1 id="clicked3"><a hre="#">' . $post->choices->c . '</a></h1></p>';
$x = $x . $lead_title . $lead_choices . $lead_choices2 . $lead_choices3 . '<!--nextpage-->';
}
$my_post = array(
'post_title' => questions,
'post_content' => $x,
'post_status' => 'publish',
'post_author' => 1
);
wp_insert_post( $my_post );
wp_link_pages() returns the pagination markup you have defined with your $default array of parameters. So you probably already have the html that you want to show returned from the wp_link_pages() function.
Assign wp_link_pages() to a variable and then echo or print out the content where you want your pagination to appear.
Like this:
$defaults = array(
'before' => '<h1>' . __( 'Pages:' ),
'after' => '</h1>',
'link_before' => '',
'link_after' => '',
'next_or_number' => 'next',
'separator' => ' ',
'nextpagelink' => __( 'Next page' ),
'previouspagelink' => __( 'Previous page' ),
'pagelink' => 'Page %',
'echo' => 1
);
$pagination = wp_link_pages( $defaults );
//Put this where you want your pagination to appear:
echo $pagination;
I just updated to Wordpress 3.5, but this crashed a little part of my code:
There is a php file, which loads a specific post with its gallery via AJAX.
The code looks like:
<?php
// Include WordPress
define('WP_USE_THEMES', false);
require('../../../../wp-load.php');
$id = $_POST['id'];
// query post with this identifier
query_posts('meta_key=identifier&meta_value='.$id);
if (have_posts()) :
while (have_posts()) : the_post();
// add content
$content = apply_filters('the_content', get_the_content());
echo '<div class="content-inner">'.$content.'</div>';
endwhile;
endif;
?>
The post contains a [gallery] shortcode. I've build my own Wordpress gallery with this code:
remove_shortcode('gallery');
add_shortcode('gallery', 'parse_gallery_shortcode');
function parse_gallery_shortcode($atts) {
global $post;
extract(shortcode_atts(array(
'orderby' => 'menu_order ASC, ID ASC',
'id' => $post->ID,
'itemtag' => 'dl',
'icontag' => 'dt',
'captiontag' => 'dd',
'columns' => 3,
'size' => 'full',
'link' => 'file'
), $atts));
$args = array(
'post_type' => 'attachment',
'post_parent' => $id,
'numberposts' => -1,
'orderby' => $orderby
);
$images = get_posts($args);
print_r($images);
}
This works with all other galleries on my site, but not with the ajax-loaded ones. And it has worked with Wordpress 3.4.
Are there changes in Wordpress 3.5 that I've overlooked?
I figured it out: If you use a gallery with images, which are already uploaded to the media library, the gallery shortcode looks like [gallery ids=1,2,3], what means, that images are only linked (and not attached) to the gallery, so post_type=attachment doesn't work.
Now i'm using regular expressions to get the image IDs:
$post_content = $post->post_content;
preg_match('/\[gallery.*ids=.(.*).\]/', $post_content, $ids);
$array_id = explode(",", $ids[1]);
It's now possible to pull all the galleries or even a single gallery using the $post->ID and get_post_galleries(). Each gallery will contain the image id list in ids as well as a list of the image urls in src. The gallery object is basically the shortcode arguments so you have access to those as well.
if ( $galleries = get_post_galleries( $post->ID, false ) ) {
$defaults = array (
'orderby' => 'menu_order ASC, ID ASC',
'id' => $post->ID,
'itemtag' => 'dl',
'icontag' => 'dt',
'captiontag' => 'dd',
'columns' => 3,
'size' => 'full',
'link' => 'file',
'ids' => "",
'src' => array (),
);
foreach ( $galleries as $gallery ) {
// defaults
$args = wp_parse_args( $gallery, $defaults );
// image ids
$args[ 'ids' ] = explode( ',', $args[ 'ids' ] );
// image urls
$images = $args[ 'src' ];
}
}