How can I call a plugin in wordpress? - wordpress

I'm trying to create my first theme on wordpress by zero.
I add Disqus plugin to manage the comments for the post.
which is the standard function to call the plugin in post page?
my current post page looks like this:
<?php
get_header('post');
//get_template_part( 'single-post-content' );
?>
<div id="slide1">
<div class="article_content">
<h2 style="margin-bottom: 50px;"><?php the_title(); ?></h2>
<div class="content">
<?php the_post(); the_content(); ?>
</div>
</div>
</div>
<?php get_template_part('post_footer'); ?>
I'd like to display the comments box under each post
how would you do it starting by zero?

You don't need to call the plugin's function.
To display the comments, you should call the comments_template function in your template and add a comments.php in your theme folder.
In the comments.php, you should call comment_form to display the default WordPress form.
And after you activate the Disqus plugin, the plugin will replace the default WP comment form by some actions and filters.
You can refer to the default WordPress theme to know how to display the comments.
The code is in twentysixteen/single.php and twentysixteen/comments.php
update
If the plugin(Disqus WordPress) doesn't work well, you could manually install Discuz on your theme. Please refer to https://help.disqus.com/customer/en/portal/articles/1183281-manually-install-disqus-on-wordpress

Related

Include Advanced Custom Fields (ACF) in Wordpress the_content()

I've inherited a project structure that uses front-page.php to render the home page. Most of the site uses the Wordpress content field, but we've switched to building new features with Advanced Custom Fields. the_content() is used throughout the codebase to render content, and I'm wondering if there is a way to include ACF layouts in the_content().
An example workaround I've had to use for the homepage is below, if I don't call the layout in this way content won't render on the page. I'm new to ACF, so if what I'm describing is a fundamental misunderstanding of how to bring ACF into an ecosystem I'd appreciate any guidance on better file structures and calling content.
<?php get_header(); ?>
<?php
if (is_page('Home')) {
?>
<div class="container">
<div class="row">
<?php
get_template_part('/layouts/home');
?>
</div>
</div>
<?php
} else {
the_content();
}
?>
<?php get_footer(); ?>
You can use ACF in addition to the original "the_content()" or "get_the_content()" functions. That content comes from the default block or WYSIWYG editor. ACF comes from additional fields that you add to your pages or posts.
<?php get_header(); ?>
<?php
if (is_page('Home')) {
$home_acf_field = get_field('field_name_from_home_acf');//this assumes that the ACF field has been added to the home page, because I'm not using the second parameter
?>
<div class="container">
<div class="row">
<?php
get_template_part('/layouts/home');
echo $home_acf_field;//this could also be placed in "layouts/home"
?>
</div>
</div>
<?php
} else {
$acf_field_from_page = get_field('field_name_from_page_acf');
the_content();
echo '<div>'.$acf_field_from_page.'</div>';//an example of where this can go
}
?>
<?php get_footer(); ?>
You can incorporate ACF in the template part, or in the page itself. You need to have the ACF field set up in the CMS to be on home or wherever, but then it's as simple as what I showed you to pull it in (my examples were assuming text fields).
You aren't asking this question, but if you are using "front-page.php" as your home page, then why do you need the if statements to show content? You can use "the_content()" in addition to your ACF fields, especially if it's the content editor from the home page. Or, you can just hide it (it's an ACF setting).
Note: I wrote this from memory, and didn't test anything, so please excuse any potential typo. :)

Buddypress Plugin Theme error

This is with respect to a buddypress addon (plugin) whose theming I am unable to do. I searched many sites but unable to get a concrete solution. In the plugins page, Header is getting disturbed if its a buddypress theme but is working fine in default wordprress themes.
I am using this code at present at the top of the template page
<?php get_header('buddypress'); ?>
<div id="buddypress">
<div id="profile">
<div class="row">
Than the following stuff like
<?php do_action( 'bp_before_member_home_content' ); ?>
<div id="item-header" role="complementary">
<?php bp_get_template_part ( 'members/single/member-header' ) ?>
</div><!--#item-header-->
I feel this is not the right way to do. I want to know if the plugin has to copy the buddypress template header without disturbing footer or sidebar how it can be done. i.e my plugin should show only the plugin content and should not disturb any part of the buddypress template.
you have to edit your buddy press header with your html structure.
and keep buddy-press functionality as it is.

creating wordpress template

I need to create a fresh wordpress template using adobe dreamweaver . I want the template with image slider , stylish menus and commenting options. please guide me from basic to end.
Maybe you'll find this tutorial helpful:
http://www.adobe.com/devnet/dreamweaver/articles/dw-wordpress-multiscreentheme.html
as well as this:
http://www.adobe.com/devnet/dreamweaver/articles/dw_wordpress_pt1.html
Wordpress Template starts with
<?php /* Template Name: Stylish Template */ ?>
<?php get_header(); ?> // go to header.php add required js file for slider & menu through wordpress function() <?php wp_nav_menu($args); //check wordpress documentation for $args.
<div id="slider">
--images will go here
</div>
<div id="content">--Content Goes here---These will be posts from any category or latest posts, look wordpress documentation for <?php comment_template() to add comments if they are disabled.?></div>

Wordpress, short codes wont work in custom theme I made

I have started to learn how to make custom themes for wordpress and have problems when installing plugins that have shortcodes. I try to add a shortcode ( usually a form plugin, i have tried two different ones and also an ecwid shopping cart yet no shortcodes have worked, yes the plugins were activated) by creating a page and using the visual/html editor. When i check the page it does not show anything. here is my single.php..
<?php get_header(); ?>
<body>
<div id="maintopwrapper">
<div class="container" id="topwrapper">
<div class="row">
<div class="span8">
<?php while (have_posts()) : the_post(); ?>
<!-- Content Here -->
<div class="row"><div class="span8 greygrad round">
<div class="padding"><div class="content" style="margin-top:25px;"><?php the_content(); ?></div></div></div></div>
<div class="row margintop"><div class="span8 greygrad round">
<div class="padding">
<?php comments_template() ?>
</div></div></div>
<?php endwhile;?>
</div>
<?php get_sidebar(); ?>
</div>
</div>
</div> <!-- end of maintop wrapper-->
<?php get_footer(); ?>
It should show since the_content() is there right? Let me know if you need anything else for me to share. Plugins I tried a gravityforms, ecwid shopping cart, and quforms..all of which the shortcodes do not work. The only way I got one of them to work is by creating a custom page theme and adding hardcoded php to call the function but I rather have shortcodes working so the theme is usuable by people who dont code.
For live example: http://modernlogic.co/wp
the "contact" page in menu is actually hardcoded in the custom theme which is not using the shortcodes like I want in the "sample page" in menu
Thanks in advance
I am a idiot... I realized that I had no page.php and so when I tried adding the shortcode to a page it referred to the index.php instead of page.php(since there was none) and so it only showed the excerpt and not the content. I figured this out because I tried adding the shortcode to a post and so when it went to single.php, the shortcode worked since it has content and not just excerpt. oh well I guess trial and error.. Thanks for trying to help me anyway

Wordpress - Post Page Associator Issues

For a client site that I am working on, the client wants to be able to associate certain custom post types to a given page. my supervisor has pointed me to the website of a previous client that did something similar. They used the Post Page Associator plugin (which seems to have been removed from the plugins list).
Here is a link to the plugin I am using: http://www.mediafire.com/?2dpbxac73rsn8l6
I've tried my best to modify the code inside the plugin to handle the custom post types I wanted to use (which the changes are included in the download). The main conflict comes from this piece of code (from the previous client's page.php file)
<?php
$sidebar = new WP_Query( $args ); //queries for posts
$sidebar = wp_plugin_post_page_associator::get_associated_posts ($post->ID); //looks for associated posts via the plugin, the main offending line of code
if ($sidebar!="") : while ( $sidebar->have_posts() ) : $sidebar->the_post();
?>
<div id="sidebar-content"> <!-- sidebar area -->
<h1 class="blue-text"><?php the_title(); ?></h1> <!-- the title of the associated post -->
<div class="divider"></div>
<?php the_content(); ?> <!-- the content of the associated post-->
<br/><br/>
</div>
<?php endwhile; else:?>
<br/><br/>
<?php endif; ?>
I was wondering if there was a way to determine what kind of post type the associated content is so I can change the WP_Query settings accordingly. If I comment out the second line of code with $sidebar, then all posts gets displayed in the sidebar. Is there a solution to this problem, or is there a better plugin for this?
I found a replacement plugin that does exactly what I need and shows me how to do it: http://www.cssigniter.com/ignite/custom-post-types-relationships/

Resources