I have been struggling with this problem for the last two weeks now, and the problem is that I am not able to display the ajax load more (and any of its post and even the button) on my custom archive page. I want to provide a sleek archive for my visitors, allowing them to just scroll in previous posts without having to use any pagination. And the strange thing is, when I echo the shortcode for the ajax load more, it doesn't display at all. When I inspect the code, it has been automatically set to visibility:hidden. What really seems to be the problem here?
How can I display this in my "page-arkiv.php"?
Plugin used: https://wordpress.org/plugins/ajax-load-more/
Code:
<h1>TEST PAGE </h1>
<?php echo do_shortcode('[ajax_load_more]'); ?>
Output:
<div id="ajax-load-more" class="ajax-load-more-wrap default" data-alm-id="" data-canonical-url="http://whatever.com/arkiv/" data-slug="arkiv" data-post-id="73">
<div class="alm-listing alm-ajax" data-repeater="default" data-post-type="post" data-order="DESC" data-orderby="date" data-offset="0" data-posts-per-page="5" data-scroll="true" data-scroll-distance="100" data-max-pages="0" data-pause-override="false" data-pause="false" data-button-label="Older Posts" data-transition="fade" data-images-loaded="false">
</div>
<div class="alm-btn-wrap" style="visibility: hidden;"><button class="alm-load-more-btn more " rel="next">Older Posts</button></div></div>
And this is my Reading settings:
Related
I'm integrating an iframe with dynamic php content in its src on a checkout congratulations page. When the process is complete the iframe with code shows in Firebug, but not on view source in the browser. If I refresh the page the content shows in the browser view source. This, is what I believe, is causing the integration to fail because the iframe is not being picked up by the online service we are using.
Its a Wordpress so the final page calls get_header(); then html/php then get_footer();. Everything in between the header and footer does not show on the view source until I refresh the page, very odd. I tried googling but I found nothing and I'm not sure what even may cause it or where to begin.
Any experience with this?
Edit.
below is the code, everything inside of and including section1 div does not show in view source.
<?php get_header(); ?>
<div class="section1">
<div class="container">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<iframe here>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>
Edit:
I still don't know why, but it had to do with destroying all PHP session and browser cookies. Time to mark this one closed. If I ever figure out why,
I'll edit this question.
I'm working on a scrollable one-page website, in which each div represents a different section. For example, url is dynaone.com/index.php, and when I click on the menu's different buttons, it changes to /index.php#s1, #s2, #s3, and so on. In section nº 2 I added another menu that works with php GET, in a way that when you click on one of the buttons, it redirects you to index.php?id=1 and so on. Of course when I first tried it, it scrolled me back to the top of the page, 'home', as I wasn't specifying the section. But when I did, assigning "index.php?id=1#s2" to the first element in the inner menu, it redirected me to section 1. It doesn't matter which number I write after "#s", it will keep putting section nº 1 on top of the page.
I'm using SMINT's demo as a base, adjusting it to my website's needs, but I couldn't find anything related to GET method issues on the plugin's page.
I would really appreciate some help with this, as it's very annoying having to go back everytime I click to correctly view section nº 2.
This is part of my inner menu:
<div id="botonera_productos"><ul>
<li> Quemadores </li>
<li> BCAAs</li> </ul> </div>
This is my php section:
if(#$_GET['id']==1) {
?>
<figure><img src="imagenes/quemadores/1.jpg"><figcaption> ULTIMATE L-CARNITINA 500 60 TABS - <b>$330</b> </figcaption></figure>
<?php } ?>
And this is the site's main menu:
<nav class="subMenu" >
<div class="inner">
Home
Nosotros
Productos
Local
Envíos
Consultas
Facebook
</div>
</nav>
Thank you.
The question isn't very clear but basically:
The anchor is an HTML construct. So once the page is already loaded, you can use #whatever to take you to wherever on that page that the anchor has been defined; ala <a id="whatever">
The PHP arguments, like ?id=1 - a new page will be loaded depending on what you use here.
You can use anchors in conjunction with a PHP page (ie. a PHP page may have multiple anchors) but you cannot load a new page with anchors alone.
Maybe Javascript will help you achieve what you want to do. With AJAX calls and the like then there are far less restrictions on how you load data.
I've been tearing my hair out over this for two days, and every time I think I've solved it, it just pops up again.
In my header.php I have the following code for displaying the number of items in the cart, and a simple show/hide div displaying the items themselves, along with a total:
<a id="miniart" href="<?php echo WC()->cart->get_cart_url(); ?>" class="cart icon red relative">
<div class="number bold">
<?php echo sprintf('%d', WC()->cart->cart_contents_count); ?>
</div>
<div>
<?php returnIcon('cart'); // This function simply displays an inline SVG ?>
</div>
<div id="cartcontents">
<div class="widget_shopping_cart_content">
<?php woocommerce_mini_cart(); ?>
</div>
</div>
</a>
I also have a filter to return the cart fragments via AJAX when a new item is added:
function woocommerce_header_add_to_cart_fragment($fragments) {
ob_start();
?>
<div class="number bold">
<?php echo sprintf('%d', WC()->cart->cart_contents_count); ?>
</div>
<?php
$fragments['#minicart .number'] = ob_get_clean();
return $fragments;
}
add_filter('woocommerce_add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment');
The filter always works - I've never had a problem with that. What's totally throwing me is that the standard, pre-processed calls in the header (cart_contents_count & woocommerce_mini_cart()) seem to be totally cached. If I add a new item, the AJAX will update both to display 1 and the actual item added; but if I change the page or refresh, it defaults back to 0 and No items. If I go to my cart, despite the mini-cart still saying I have nothing, the actual cart page displays the cart contents correctly.
It only appears to update if I go to my cart page and delete something from my cart; for example, if I've actually got 7 items in my cart but the minicart displays 0, and then delete an item from my cart, suddenly the minicart will corectly display 6. However, from that point it will stay at 6, even if I add another dozen items.
Here's what I've tried:
Change the classes/IDs of the elements (i,e, #minicart to #tinycart, etc.) - works once, then immediately starts caching again.
Turned off the filters: This has no effect, since the filter is only for returning fragments when new items are added. Also worth noting that there doesn't appear to be any kind of AJAX call fired at page load that would interfere with the minicart display.
Turned off all plugins except WooCommerce: made no difference.
Turned off 'Enable AJAX add to cart buttons on archives' in WC settings: This kinda works, insofar as it reloads the entire page when an item is added, and the minicart displays number of cart items correctly (hooray!), but obviously disables the ability to add items via AJAX, which is a requirement of the site (boo.)
Deleting my own mini-cart.php template file: Just in case, to see if that was an issue. Made no difference.
Putting the woocommerce_mini_cart() function literally anywhere else: This, infuriatingly, works. If I take this function and the echo sprintf('%d', WC()->cart->cart_contents_count) line and put them anywhere - within the header, within the page body, even inside the same element that's getting 'cached', they work. They display the correct number of items, and the correct list of items. But the other calls to this function, as noted above, still appear to be cached.
As noted, this occurs even with no other plugins running; it happens both locally (a completely standard XAMPP installation on Windows) and remotely (a niftier nginx setup, slightly newer PHP version), and neither have any kind of caching enabled.
Any suggestions would be very gratefully received, as I have totally lost my mind on this one.
A bit late but I tried your code and it worked for me with some small modifications.
I have changed the a id from miniart to minicart and commented out the returnIcon
<a id="minicart" href="<?php echo WC()->cart->get_cart_url(); ?>" class="cart icon red relative">
<div class="number bold">
<?php echo sprintf('%d', WC()->cart->cart_contents_count); ?>
</div>
<div>
<?php //returnIcon('cart'); // This function simply displays an inline SVG ?>
</div>
<div id="cartcontents">
<div class="widget_shopping_cart_content">
<?php woocommerce_mini_cart(); ?>
</div>
</div>
</a>
Another change was to rename woocommerce_header_add_to_cart_fragment to wif_woocommerce_header_add_to_cart_fragment
function wif_woocommerce_header_add_to_cart_fragment($fragments) {
ob_start();
?>
<div class="number bold">
<?php echo sprintf('%d', WC()->cart->cart_contents_count); ?>
</div>
<?php
$fragments['#minicart .number'] = ob_get_clean();
return $fragments;
}
add_filter('woocommerce_add_to_cart_fragments', 'wif_woocommerce_header_add_to_cart_fragment');
Im working on a Wordpress portfolio site and there is a line of text
<?php get_template_part( 'post-meta-page' ); ?>
that pulls information from that file and displays it on the page. Right now it displays only the title of the blog/page. I want it to display a unique line of text for each page while keeping the original title. I looked into it a little bit and this could be referred to as parsing?
Example: from external file.
<html>
<p class="homepage">Text for homepage</p>
<p class="interior">Text for interior page</p>
<p class="contact">Text for content page</p>
</html>
In other words, I want to call a specific class on one page and another class in another page. Any snippet of Javascript or PHP that can do this?
You need to edit the post-meta-page page and check where you are and add the appropirate text.
For example:
if(is_home()){
<p class="homepage">Text for homepage</p>
}
I have a web page I am working on in WP which needs some customization.
Firstly I have created a page template that will be used over and over again, only changing parts of the content. I am wondering about available options for me when enabling this fact, through the Admin panel in the HTML Editor(if possible)...
Hope my question is clear enough for you all.
Let me add some code to show what I am trying to accomplish.
<div id="header-style">
<?php get_header();?>
</div>
<div id="content">
<div id="about">
//This is what i want to be able to edit
</div>
<div id="features">
//This is what i want to be able to edit
</div>
</div>
Dino:
There are lots of ways you could do this. The main question I would ask you is, who is going to be adding/editing this content? If you're going to have a community of people adding content, the input needs to be stripped and sanitized (to avoid injecting tags or other harmful content). If its just going to be you, then here's the easiest/fastest solution:
Use custom fields. If you can't see them in the post/page edit screen, go to the little tab on the top right of the post-edit screen that says Screen Options (or something like that) and click "Custom Fields".
Once you can see the Custom Fields edit box, you can add as many fields as you want. These are stored as post meta data. You can use the <?php the_meta(); ?> function in the loop to display all of your custom fields.
You can access a specific field by using get_post_meta(). You pass in the postID and the key of the meta field:
<?php echo get_post_meta(get_the_ID(), 'my_key'); ?>
So, for your example, you would add in the post-edit screen:
about: Some text to go in the about section.
features: Some text to go in the features section.
Then, you would access these on your page like so:
<div id="header-style">
<?php get_header();?>
</div>
<div id="content">
<div id="about">
<?php echo get_post_meta(get_the_ID(), 'about'); ?>
</div>
<div id="features">
<?php echo get_post_meta(get_the_ID(), 'features'); ?>
</div>
</div>