How to add extra Widgets in wordpress? - wordpress

In my current WordPress theme, i have some 5 widgets.
I tried with plugins available on internet but that not solved my problem.
I want to use more widgets in my theme in single sidebar.
How can i add more widgets in WP theme?
Thanks

Most widgets give you a shortcode to put into one of the pages that wil be echoed out through the the_content(); function.
So if you would like to process those shortcodes in the PHP to make them in custom places would probably be your best bet.
You can do that like this:
<?php echo do_shortcode( $content ) ?>
Here is the reference

Related

How to add custom content in sidebar of each Wordpress post?

I want to integrate specific text (text, links, images) making reference to specific sentences of my blog post.
Is it possible to do it with code or using a plugin ?
I send you a sketch :
This is the sketch
That is common need and often Aside in WordPress is talked for it. There are WP plugins like Aside Widget, Custom Sidebars for ordinary needs. But if you need too much custom stuff like my website's "About this Article" sidebar widget - https://thecustomizewindows.com/2016/09/limitations-of-openvz-virtualization-to-guest-cloud-server-vps/ then it is better to use
Otto's this plugin to use PHP in text widget - https://wordpress.org/plugins/php-code-widget/ and use PHP. In my case, rest is PHP code like this on sidebar (I can use shortcode too) :
<?php if(is_single()) : ?>
<h3>About This Article</h3>
<strong>Title:</strong> <?php echo get_the_title(); ?><br />
Published on: <?php the_time('Y-m-d') ?>
<br />
...
// rest of the code
<?php endif; ?>
Obviously you can call post image thumbnail with WordPress function.
As you need specific text, you may think about combining Pull Quote Plugin or Aside Widget to mark the specific like and echo it with PHP.
As other options -- you can use CSS3 to automatically select first line, first paragraph, second sentence. You can use Javascript to conditionally mark.
Best possible customisation I saw is on BMJ's sidebars. They use Drupal, not WordPress. BMJ has beautiful sidebar -- (as example) - http://www.bmj.com/content/355/bmj.i4924 Drupal has description of the work - https://www.drupal.org/node/1557636 Sadly I lack idea about Drupal. I tried a lot behind using WordPress for academic purpose.

I want to use WP UI tab in my header.php

I want to use WP Ui tab in header.php instead of any pages or post.in pages i can add like this:-
[wptabs mode="horizontal"] [wptabtitle] Map[/wptabtitle] [wptabcontent]map detail[/contentment][wptabtitle] Get Bids[/wptabtitle] [wptabcontent]bid detail[/wptabcontent] [/wptabs]
thanks in advance
<?php echo do_shortcode('[wptabs mode="horizontal"] [wptabtitle][/wptabtitle] [wptabcontent][/contentment][wptabtitle][/wptabtitle] [wptabcontent][/wptabcontent] [/wptabs]'); ?>
You can use the do_shortcode function of wordpress for this purpose.. e-g add the above function in your header.php . If you are not programmer then i suggest you to take help from some professional developer.

How to use wordpress shortcode in template

I need help with wordpress shortcode. I have written shortcode function in functions.php in my theme files. Now I create page in wordpress administration and then I need to place this shortcode into special place in my theme but with content which I wrote in administration.
I hope that you understand what I mean.
Thank you for your help.
In your template code:
<?php echo do_shortcode('[your-shortcode]'); ?>
Replace [your-shortcode] with whatever your shortcode is, including parameters/attributes and/or closing tags if required.

Wordpress plugin shortscodes in other plugins?

I'm developing a plugin that creates custom wordpress pages, however I ran into a problem when trying to get shortcodes from other plugins to integrate into my plugin, well more like I couldn't find any info on it.
For example if someone uses my custom page builder and adds a short code [gallery] that is associated with an enabled plugin, I want the shortcode to do it's thing.
Could anyone point me in the right direction for this?
Try wordpress
http://wordpress.org/plugins/synved-shortcodes/
while this plugin let's you integrate shortcodes on every wordpress page , I suppose that you issue is with wordpress functions.php file where you can have a look at , with this plugin installed !
You can check if a shortcode exist before printing it with the function shortcode_exists() (https://codex.wordpress.org/Function_Reference/shortcode_exists)
Example:
<?php
if ( shortcode_exists( 'gallery' ) ) {
// The [gallery] short code exists.
}
?>
Then, if it exist and you want to print that shortcode with PHP code you should use do_shortcode() function (https://developer.wordpress.org/reference/functions/do_shortcode/)
Example:
<?php echo do_shortcode('[gallery]); ?>
Always use in WordPress's in-built
the_content
hook to print your custom page content.
WordPress by default process all shortcodes before outputting any stuff from this hook.
More info can be found here: https://codex.wordpress.org/Function_Reference/the_content

Enable shortcodes in a wordpress theme

I develop a new theme for wordpress 3.3.1 from scratch and shortcodes are not working on it.
As I searched until now it is a matter of filtering the content containing the shortcode, filter code added in a theme specific location(shorcodes are working with another theme).
So, my question is : What is the code for a general shortcode theme enable ?
To execute a single shortcode, run it with
echo do_shortcode('[your_short_code]');
If the shortcode(s) are in the post content, make sure you're displaying it with
<?php the_content();?>
Or
<?php echo apply_filters('the_content',$post_content);?>
Or
<?php echo apply_filters('the_content',$wp_query->post->post_content);?>
The important thing is: if you aren't using the function "the_content()" you need this line <?php echo apply_filters('the_content',$wp_query->post->post_content);?> where in the second argument you have to put the variable of the post content you want to show.
I had to save the theme's content to a variable and then use the second example.. Worked like a charm.
$mycontent = ot_get_option('rightcontent');
echo apply_filters('the_content',$mycontent);

Resources