I had made my theme to be compatible with woocommerce, by creating woocommerce.php, and adding a custom function in my functions.php file which is
add_theme_support( 'woocommerce' );
And this is how my woocommerce.php file looks like :
<?php
global $mandigo_options, $dirs;
get_header();
// heading level for page title (h1, h2, div, ...)
$tag_post_title_single = $mandigo_options['heading_level_post_title_single'];
?>
<td id="content" class="<?php echo ($mandigo_options['sidebar_always_show'] ? 'narrow' : 'wide'); ?>column"<?php if (mandigo_sidebox_conditions($single = true)) { ?> rowspan="2"<?php } ?>>
<div class="woocommerce">
<?php woocommerce_content(); ?>
</div>
</td>
<?php
// if we have at least one sidebar to display
if ($mandigo_options['sidebar_always_show'] && $mandigo_options['sidebar_count']) {
if (mandigo_sidebox_conditions($single = true))
include (TEMPLATEPATH . '/sidebox.php');
include (TEMPLATEPATH . '/sidebar.php');
// if this is a 3-column layout
if ($mandigo_options['layout_width'] == 1024 && $mandigo_options['sidebar_count'] == 2)
include (TEMPLATEPATH . '/sidebar2.php');
}
get_footer();
?>
Everything is appearing fine now, but I can't find the add to cart button and also all the elements that uses javascript or jquery are not loading.
I had tried :
To use wordpress JQuery updater
To put the jquery library reference in the header.php
Deactivating all plugins
I had all the fields of the necessary elements in woocommerce field like the price, but its obvious that this is a JS or JQuery error.
And here is a link to the site is product page :
http://www.doctor-detail.com/product/gift-card-product-2
Any help would be much appreciated!
When I inspected the site and checked the console I found that although I was linking to the latest jquery in the header of my site, it was using the main jquery of the theme.
So, all I needed to do is to remove the theme is Jquery file from the JS folder.
After that woocommerce was working fine.
You should use wp_enqueue_script() in functions.php instead of linking in a header.php, Plese keep in mind JQuery in enqueued by default. If you need to change version, fist you have to deregister the default one.
Related
I created a website in WordPress (Website: Link) using this theme.
I would like to know, how can I add a [timeline-express] widget after the image slider?
(I tried to modify idyllic-functions.php, using:
...
</div> <!-- end .main-slider -->';
echo $idyllic_category_sliders_display;
echo add_filter( 'widget_text', 'timeline-express');
...
,but the site crashes.)
Open this file: idyllic/inc/front-page/front-page-features.php and add this following line on line 34:
<?php echo do_shortcode('[timeline-express]'); ?>
Just above this line:
<div class="our-feature-box <?php echo esc_attr($feature_box_class); ?>">
So, your updated code will be also follows:
<?php echo do_shortcode('[timeline-express]'); ?>
<div class="our-feature-box <?php echo esc_attr($feature_box_class); ?>">
Note that, it's always a good practice to create a child theme, copy file/template to the child theme directory, and then modify your codes. Otherwise, you will lose your modified codes once the theme is updated.
PS: please try to follow what #tacoshy mentioned in his comment while asking questions in stackoverflow.
I want to have a overlay over my content site. So if somebody clicks on a link a article is loaded into the covering overlay Div
Everything is working fine except the output is not working properly.
<script language="javascript">
$( ".iddd" ).click(function() {
var aid = $(this).prop('id');
$('#overlaycontent').load('http://www.example.com/overlay.php', { id: aid });
});
Test PHP Script:
<?php
include ("config.php");
$ID = $_POST['id'];
echo $ID;
?>
That´s how my links are placed:
<a class="iddd" href="#overlay" id="6337cab172">
The id should be loaded into the script so I can access my articles but i guess the Jquery is not working properly.
I looked at this overlay with dynamic php content the right way?
but still it doesnt post the ID properly!
Not sure what is in config.php and if missing that could cause your problem, but to include a file, you don't use parenthesis, but only quotes, so, instead of
include ("config.php");
just
include "config.php";
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I created a dynamic table in PHP I want to put on a WordPress page.
I can open the PHP locally in my browser and the CSS and JavaScript I use to create the table work.
When I try to include the PHP file in a WordPress page with a short code, the WordPress CSS is used on it and the JavaScript is not even run. What is the best way to implement this? Is it even possible?
If you need or want to use a shortcode, then that means it can be ran on any page or post at any time and so you should always include the necessary JS and CSS. You include JS and CSS in WordPress using a function that contains wp_enqueue_script() calls, and wp_enqueue_style() calls. The function that includes those calls should hook to wp_enqueue_scripts (this link has good examples), and it should be located in the functions.php file of your WP theme or a file that is included within the functions.php file.
Then the shortcode function itself can just be built out as normal, located inside the functions.php file for your theme or a file that the functions.php file includes. If you're not sure how to do that, here's an example below using output buffering.
add_shortcode('shortcode_name_here', 'shortcode_function_name_here');
function shortcode_function_name_here(){
// Begin output buffering
ob_start();
// Build table example, replace with your code beginning here
// WP_Query, grab up to 100 blog posts, no paging
$query_args = array (
'posts_per_page' => 100,
'post_type' => 'post',
'no_found_rows' => true,
);
$wp_query = new WP_Query( $query_args );
if( $wp_query->have_posts() ) :
?>
<table>
<tr>
<th>Titles</th>
</tr>
<?php while( $wp_query->have_posts() ) : the_post(); ?>
<tr>
<td><?php the_title(); ?></td>
</tr>
<?php endwhile; ?>
</table>
<?php
// Alternative message if there's no posts
else:
?>
<h3>Sorry, but we have nothing for you.</h3>
<?php
endif;
// End build table example, end your custom code here
// End buffering, save, return
$output = ob_get_clean();
return $output;
}
I don't think you can add HTML/JS/PHP with shortcodes. You can however add PHP to the wordpress files directly in the wp-content directory or by adding your own plugin. The easier way would be to access the Wordpress files via the dasboard : go to your dashboard, click on the Appearance tab on left toolbar and on the Editor tooltip. From there you can modify the template files of your theme and create new PHP files.
In WP 4.2 project I attach js files like:
add_action('wp_print_scripts', array(&$this, 'admin_load_scripts'));
...
function admin_load_scripts()
{
wp_register_script('BackendArtistsSongsJs', $this->plugin_url . 'js/backend-scripts.js');
...
But I want different pages to attach different js files.
I can do it in these ways:
In admin_load_scripts to parse parse $_SERVER and depending
on current url to attach js file I need.
In related php file
to include this file I need.
If there is a better way for this and which way do you prefer?
If you want to load a script on a particular page you can use
<?php if( is_page('<page-name>')) { ?>
// You import
<?php } ?>
You can check your page and add this script for js file add.
like if you want add js file in home page .
function admin_load_scripts()
{
<?php
if(is_page('home')) { ?>
wp_register_script('BackendArtistsSongsJs', $this->plugin_url . 'js/backend-scripts.js');
}elseif(is_page('second page name')){
//Add code for second js script file .
}
...
I have a giant image/button in my header on every page that leads my users to a form they fill out, I want to remove that image/button on the form page itself, hoping to use css. I'm using wordpress, but this form is not a wordpress page, its located in a different directory and its called index.php. How do I go about hiding the image?
Within index.php, the first few lines there is a call to get_header() which loads the header so i thought to put this bit of code right after it:
<?php if ( is_page('mysite.org/the-index-page/') ) { ?>
<style type = "text/css">.order-btn { display: none; }</style>
<?php } ?>
however nothing happens. Am I doing this right or is there a better way to do it?
A better solution is probably to remove the button from that specific page. It sounds as if the button markup is inside your header.php file. You could try this:
<?php if ( !is_page( 'the-index-page' ) ) : ?>
// Button markup here
<?php endif; ?>
And if it's not working, this should:
$url = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
<?php if ( !( $url == 'mysite.org/the-index-page/' ) ) : ?>
// Button markup here
<?php endif; ?>