WP the_content display plugins attachments only - wordpress

This might be a silly question since I'm new to wp but i'm trying to create a custom post feed.
Basically i have this loop
while ( have_posts() ){
the_post();
the_title();
the_post_thumbnail('content-thumb');
//and here i have installed facebook share plugin
//so if i put the_content() it would display share button
//the problem is it also display post text and everything else while i only
//need that plugin button or whatever comes with that plugin
}

The Facebook share plugin is most probably hooking the button code to the_content filter hook. The only way to avoid both 'the content' and the 'facebook button' from both displaying at once is to unhook the button from the_content using remove_filter() and then add the button manually to the page.
Read more about WordPress hooks in the Plugin API/Hooks article.
Refs:
http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content
http://codex.wordpress.org/Function_Reference/remove_filter

Related

Embedded Wordpress form plugin shortcode not displaying in page

I currently creating a Wordpress custom theme with the Ninja Forms plugin, for one of the pages Ive embedded the Ninja Form using the shortcode such as [ninja_form id=2] and Ive inserted the post directly into the inner page as such
$id = $_GET['page_id'];
$post = get_post($id, 'OBJECT', 'display');
//display the post
echo '<h1 class="dark">'.$post->post_title.'</h1>';
echo $post->post_content;
But the embedded form shortcode doesnt resolve to actually load the form into the page. What Im not doing??
try checking your Javascript files and CSS files that it doesn't affect the plugin you are using, because some of javascripts and JQueries overrides on the plugins you are using.

Can Shortcodes be used in a Static WordPress Homepage?

I have a Static page set as the home page of my wordpress website. It has a custom shortcode to show a woocommerce catalog based on my own meta query.
When I add valid products, it does not show up immediately or even after a while. However, if I publish the static page, then it shows up magically, thus leading to my question.
What are my alternatives, if I want to show my shortcode on a static home page?
I think this is my problem and nothing else, because I tried disabling all plugins and clearing the cache, but still it did not show the latest added products.
You can edit the template of your theme adding the do_shortcode() function where you want the shortcode to be displayed, for example:
<?php echo do_shortcode( '[contact-form-7 id="91" title="quote"]' ); ?>

Woocommerce product form fields

I would like my product page that customers fill 5 text fields and choose 1 field type radio.
So my product page is a form where customers ask a question, fill some information and choose a paid option.
Like this french page => http://www.avocat-bervard.com/paiement-honoraires-consultation-juridique/
Is it possible with Woocommerce ?
If so, can you explain me how ?
Thanks.
You can create nice forms with plugin Ninja Forms :). Its a very cool plugin, with a couple of settings: sending emails, when submitting forms, etc.
It is also supports shortcodes, with this method you can implement your form on every single product page, or even display it in a widget area.
For widget area:
You need to enable shortcodes first in functions.php
add_filter('widget_text', 'do_shortcode');
Then call the shortcode in Appearence - Widgets
For template:
You need to edit the file where you want this form to display, single-product.php, meta.php :) etc.
To insert shortcode in template file you need to use the below code:
<?php echo do_shortcode( $content ) ?>

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

In Wordpress CMS, the controls under the WYSIWYG editor

I want to create a wordpress plugin where it adds additional controls underneath the WYSIWYG editor when adding pages/posts. But I don't know what keywords I'm supposed to google for to find relevant tutorials on how to do it.
Can someone provide me with resources?
It's called add_meta_box() - call it within a hooked admin_init function like so;
function my_custom_meta_box()
{
add_meta_box(
'my_meta_box_id',
'My Meta Box Title',
'my_meta_box_callback',
'post', // either post, page or link,
'normal', // position of the meta box,
'high' // position priority
);
}
add_action('admin_init', 'my_custom_meta_box');
function my_meta_box_callback()
{
echo 'This is the content of my meta box!';
}
Do you want the filter reference for hooks to add to the editor? Plugin API/Filter Reference « WordPress Codex There are lots of plugins that add controls to the editor: WordPress › WordPress Plugins - TinyMCE
I've written a good tutorial on adding WordPress Meta Boxes additionally check out my WPalchemy Meta Box PHP Class which will help you create meta boxes with ease.

Resources