Custom Loop and Infinite Scroll

I am using customized version of _s theme where I have Product CPT. In the following files, I need to use Infinite scroll (provided by Jetpack) - archive-products.php taxonomy-[tax-name].php home.php archive.php Now, the problem is most of these templates use custom loop (using WP_Query which ends with pagination after while()). I have used following code in functions.php after activating jetpack and Photon module - function vg_infinite_scroll_init() { add_theme_support( 'infinite-scroll', array( 'container' => 'page-content', 'footer' => 'page', 'type' => 'click', 'render' …
Category: Web

Change $content_width based on screen size (functions.php)

I've got a WordPress install where I'm trying to change this content_width code: if( ! isset( $content_width ) ) $content_width = 290; in my functions.php file based on the users screen size. I've tried using CSS media queries, but for our particular use-case, I need to be able to change this in the functions.php file based on the users screen size. Ideally 1080 for Desktop, 720 for tables, and 290 for mobile. Any ideas?
Category: Web

how to get jetpack's infinite scroll to work with woocommerce?

I am trying to get Jetpkack's infinite scroll to work with the WooCommerce product archive template. I have added the following code to my theme, after installing Jetpack, and I do see the sticky footer that shows when infinite scroll is enabled, and I see it loading default seven products instead of normal output, which leads me to assume the infinite scroll function is firing: function mytheme_infinite_scroll_init() { add_theme_support( 'infinite-scroll', array( 'container' => 'content', 'render' => 'mytheme_infinite_scroll_render', 'footer' => 'wrapper', …
Category: Web

Publicize in Jetpack stopped working on Custom Post Type it works in Blog Posts

Hello guys I have a site which I installed JetPack in order to use Publicize to add the functionality to my CPT I added this code: 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ,'author', 'publicize' ), It was working perfect but a few days ago it stopped working I have used this article to troubleshoot but with not success https://jetpack.com/support/publicize/troubleshooting-publicize/ have you have this issue before? thank you for your help.
Category: Web

Hooked into wp_get_attachment_caption to add content to the default description; not working for jetpack slideshow. Why?

I would like to have my image descriptions added to every image caption on my site. No matter where the caption is shown, I would like to have the description prepended, if there is one to this image. Nothing easier than that, I thought, and filtered the wp_get_attachment_caption to make sure it happens. And it works for every image displayed anywhere. Post thumbnails, images in posts... Except for the images loaded in a jetpack slider. The modified caption, although Jetpack …
Category: Web

Show views count for pop up post

I am using jet pop up plugin to open a custom post type in a pop up. The idea is to track which post is more interesting for users so we need to show post view counts or track click events and show them to wordpress admin on the custom post type listing. I tried using different plugin to show post count but since post is opening in modal, no specific URL, no page load... plugins are not counting views …
Category: Web

Class 'Jetpack_Options' not found, composer dump-autoload not helping

I am cloning a friends WP installation using mysqldump, rsync and docker to fetch all files and data. When running the site, I get the following error: Fatal error: Uncaught Error: Class 'Jetpack_Options' not found in /var/www/html/wp-content/plugins/jetpack/class.jetpack.php:2154 Stack trace: #0 /var/www/html/wp-content/plugins/jetpack/class.jetpack.php(702): Jetpack::get_option('edit_links_caly...') #1 /var/www/html/wp-content/plugins/jetpack/class.jetpack.php(403): Jetpack->__construct() #2 /var/www/html/wp-content/plugins/jetpack/load-jetpack.php(89): Jetpack::init() #3 /var/www/html/wp-content/plugins/jetpack/jetpack.php(149): require_once('/var/www/html/w...') #4 /var/www/html/wp-settings.php(371): include_once('/var/www/html/w...') #5 /var/www/html/wp-config.php(90): require_once('/var/www/html/w...') #6 /var/www/html/wp-load.php(37): require_once('/var/www/html/w...') #7 /var/www/html/wp-blog-header.php(13): require_once('/var/www/html/w...') #8 /var/www/html/index.php(17): require('/var/www/html/w...') #9 {main} thrown in <b>/var/www/html/wp-content/plugins/jetpack/class.jetpack.php</b> on line 154 The class exists, it is not …
Category: Web

i1.wp.com url problem (Jetpack not installed)

I added the following code to the functions.php file add_filter( 'avatar_defaults', 'new_gravatar' ); function new_gravatar ($avatar_defaults) { $myavatar = 'link'; $avatar_defaults[$myavatar] = "name"; return $avatar_defaults; I'm taking the profile picture from my own server. But there is a problem! "I1.wp.com" appears at the beginning of the url in the profile image. What is the reason? So it looks like: "https://i1.wp.com/mysite.com/images/myavatar.png" I've disabled all plugins. But the result was not successful. I'm dealing with it in days. How do we delete …
Category: Web

How to stop xmlrpc attacks without disabling component to allow JetPack to work in WordPress?

I manage a WordPress website using an virtual machine in the cloud, and lately, I noticed a lot of unwanted requests to the xmlrpc.php component that are slowing down the site causing high CPU loads. If it was for me, I would disable it entirely, but the site uses the JetPack plugin which relies on xmlrpc. So, my question is: how to allow JetPack access to xmlrpc while blocking everyone else and without disabling xmlrpc on the server? The site …
Category: Web

Shortcode not working in Jetpack Top Posts & Pages widget

I've added [year] shortcode to some of my posts' titles. I used this in functions.php to enable this shortcode: add_shortcode( 'year' , 'current_year' ); function current_year() { $year = date("Y"); return "$year"; } I then added this too to enable shortcodes in widgets: add_filter( 'widget_text', 'do_shortcode' ); But the shortcode doesn't work in the post titles list shown by Top Posts & Pages widget by Jetpack. How do I fix it?
Category: Web

Removing the main link to Jetpack from the menu

I need to remove the link to the Jetpack settings, but not the links to Omnisearch and Site Stats from the admin menu for everyone not having an administrator role: For this, I came up with this code: function remove_posts_menu() { if (!current_user_can('administrator')) { remove_submenu_page('admin.php?page=jetpack', 'admin.php?page=jetpack'); } } add_action('admin_init', 'remove_posts_menu'); (Reference for the remove_submenu_page() function) However, this doesn't work. I did check that the function is called and so by adding remove_submenu_page('tools.php', 'tools.php'); - when this is added to the …
Category: Web

Customizing JetPack Publicize Sharing

I want to know how to setup the final code to add to my theme Function.php file to let jetpack publicize share as this : Post Title + Post link Using this guide here : https://lobby.vip.wordpress.com/wordpress-com-documentation/customizing-publicize-sharing-behavior/ I'm not familiar with filter/actions
Category: Web

Uncaught TypeError: r is not a function

I built a plugin that registers a Gutenberg block that prints a simple Mailchimp form. The plugin works with no issues. But, if I activate Jetpack and try to edit any page or post, I get a blank screen and multiple Uncaught TypeError: r is not a function console errors such as this one with little variations: editor.js?ver=9.1:6 Uncaught TypeError: r is not a function (https://domain.com/wp-content/plugins/jetpack/_inc/blocks/editor.js?ver=9.1) at editor.js?ver=9.1:6 at Array.forEach (<anonymous>) at e.exports (editor.js?ver=9.1:6) at f (editor.js?ver=9.1:6) at Module.<anonymous> (editor.js?ver=9.1:18) …
Category: Web

How to disable Jetpack modules such as Stats?

I want to disable some of the Jetpack modules such as Stats in order to check if they make the web site slower or not. But I couldn't see an option to disable modules one by one. Of course, one can disable the Jetpack plugin as a whole. Is there a way to disable Stats module only?
Category: Web

Solved - Inserting content inside the WordPress loop

I currently trying to insert a block of custom code inside the WordPress posts loop which is using JetPack's infinite scroll functionality. In theory, this should be quite simple but is proving otherwise. this is what I have currently written: <?php $count = 0; while( have_posts() ) : the_post(); get_template_part( 'content-post', get_post_format() ); if ($count === 4) { get_template_part( 'block-one', get_post_format() ); } $count ++; endwhile; ?> So, if the count is at 4 insert the custom block. However, when …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.