using wordpress function is_frontpage() to control supersized slideshow - wordpress

iam trying to control supersized slideshow with this code
<script type="text/javascript">
function ToggleSlideShow(){
api.playToggle();
}
</script>
</head>
<body>
//Check frontpage
<?php if (is_front_page() ) { ?>
//not frontpage
<?php } else { ?>
//call script and pause slideshow!
<script type="text/javascript">
ToggleSlideShow();
</script>
<?php } ?>
But it dosnt work, can anyone please help?

I gave up :-) instead i just loaded a different header using the if_front_page()

Related

How to disable Scroll Effect in WPForms Plugin Form WordPress

I am using WPForms plugin with a Multipage Form. But the thing is When I click NEXT on an empty required field the page scrolls down I don't know why. How to disable scrolling effect. Please help
Link: https://platinumcapitalconnect.com/
You may try as below:
function wpf_disable_multipage_scroll() {
?>
<script type="text/javascript">window.wpforms_pageScroll = false;</script>
<?php
}
add_action( 'wpforms_wp_footer', 'wpf_disable_multipage_scroll' );
// Disable scrolling on error and submissions.
function wpf_dev_disable_scroll_effect_on_all_forms( $forms ) {
foreach ( $forms as $form ) {
?>
<script type="text/javascript">
wpforms.scrollToError = function(){};
wpforms.animateScrollTop = function(){};
</script>
<?php
}
}
add_action( 'wpforms_wp_footer_end', 'wpf_dev_disable_scroll_effect_on_all_forms', 10, 1 );`enter code here`

wordpress onepager - redirect all pages to frontpage

Anyone have simple method for one pager wordpress site? I mean redirecting all pages to frontpage. I dont want to delete all template files and meta nofollow is too simple. Any ideas, plugins, htaccess tricks? Thanks
Write this in your functions.php:-
add_action('wp_head', 'my_page_redirect', PHP_INT_MAX);
function my_page_redirect(){
if( !is_front_page() ) {
?>
<script type='text/javascript'>
setTimeout(function() {
document.location = "<?php echo site_url(); ?>"; }, 500
);
</script>
<?php
}
}

wp 3.3.1 ajax pagination issue, pages won't advance at all

I'm trying to add ajax pagination to wp 3.3.1 and can't get it to work. I got the ajax portion working, however the pages just won't advance. Basically everytime I click "next" it will reload the current page.
I have the following code, maybe some expert could give me some hint or help. I have demo site setup if you need to take a look it.
Here is the code
<div id="clip_block"><div id='contentInner'>
<?php echo $post->ID ?>
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$wp_query->query('cat='.$post_categories.'&posts_per_page=6&paged='.$paged);
?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
/* my content */
</div></div>
<?php endwhile; ?></div></div>
<div id='postPagination'>
<?php previous_posts_link('Newer Entries »') ?>
<?php next_posts_link('« Older Entries') ?>
</div>
This is what I have in my header:
<script type="text/javascript" charset="utf-8">
jQuery(document).ready(function(){
jQuery('#postPagination a').live('click', function(e){
e.preventDefault();
var link = jQuery(this).attr('href');
jQuery('#clip_block').html('Loading...');
jQuery('#clip_block').load(link+' #contentInner');
});
});
jquery.js is loaded as well.
thanks for the help
I don't know for sure, but speaking from experience this isn't the best way to use AJAX in WordPress. Whenever I use AJAX in WP, I specifically send the request to wp-includes/admin-ajax.php which handles the request.
Can you provide a link? I'll take a look.

Wordpress navigation using wp_dropdown_pages without submit button

I'm tyring to make a simple drop down navigation GUI using wp_dropdown_pages() something along the lines of this non functioning code;
<form action="<?php bloginfo('url'); ?>" method="get">
<?php wp_dropdown_pages(array('echo' => '1')); ?>
<onchange='return this.form.submit()'>
</form>
I know its somethinng to do with the echo, I think,. PS Dont want to use a submit button. Many thanks in advance
Have worked out an what was going on from a wordpress [post]:
http://wordpress.org/support/topic/is-the-new-dropdown_categories-working?replies=13#post-657759
<?php wp_dropdown_categories('show_option_none=Select category'); ?>
<script type="text/javascript"><!--
var dropdown = document.getElementById("cat");
function onCatChange()
{
if ( dropdown.options[dropdown.selectedIndex].value > 0 )
{
location.href = "<?php echo get_option('home');
?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
}
}
dropdown.onchange = onCatChange;
--></script>

unable to get wp_ajax hook to work in wordpress

//the homepage
$(document).ready(function(){
myplugin_cast_vote(20);
});
//the plugin
<?php
add_action('wp_head', 'myplugin_js_header' );
function myplugin_js_header() // this is a PHP function
{
// use JavaScript SACK library for Ajax
wp_print_scripts( array( 'sack' ));
// Define custom JavaScript function
?>
<script type="text/javascript">
//<![CDATA[
function myplugin_cast_vote(posts)
{
$.post("<?php bloginfo( 'wpurl' ); ?>/wp-content/themes/fullscreen/function.php",
{
action : "process_thumbs" ,
numposts : posts,
results_div_id : output
});
} // end of JavaScript function myplugin_cast_vote
//]]>
</script>
<?php
add_action('wp_ajax_process_thumbs', 'my_action_callback');
add_action('wp_ajax_nopriv_process_thumbs', 'my_action_callback');
} // end of PHP function myplugin_js_header
?>
//functions.php
function my_action_callback(){
alert('sdfsdf');
$numposts = $_POST['numposts'];
$results_id = $_POST['results_div_id'];
die( "document.getElementById('$results_id').innerHTML = '$numposts'" );
}
I might not even sure my code is in the right place as I didnt really understand wordpress's example.
The homepage executes the plugin function that makes the ajax call. I add the actions and direct it to the callback function in functions.php. Of course at that point the callback isn't being run.
Any ideas?
You should post data to site_url('/wp-admin/admin-ajax.php') instead of your function.php

Resources