Explode Content within specific HTML element

I am trying to insert some ad code in a site after X number of elements. The base code I am using was from using tags (from: http://www.wpbeginner.com/wp-tutorials/how-to-insert-ads-within-your-post-content-in-wordpress/): function prefix_insert_after_list_item( $insertion, $paragraph_id, $content ) { $closing_p = '</p>'; $paragraphs = explode( $closing_p, $content ); var_dump($paragraphs); foreach ($paragraphs as $index => $paragraph) { if ( trim( $paragraph ) ) { $paragraphs[$index] .= $closing_p; } if ( $paragraph_id == $index + 1 ) { $paragraphs[$index] .= $insertion; } } return implode( '', …
Category: Web

For some time, some of my pages do not display the content anymore. Any idea where this could be coming from?

I recently worked on this website : https://semaine.com/ But since some time the content of the pages https://semaine.com/classroom/ and https://semaine.com/cinema/ are not displayed anymore. The pages load, the navbar and the footer are there but not the content. It works locally on my computer with MAMP but not online. I tried several things like disabling various plugins, re-generating links, restoring the theme from my local version, ... Here is the content of the cinema.php file: <?php /** * Template Name: …
Category: Web

Adding div to WordPress page content

I am wondering if there is a way to add div to specific elements in the WordPress page content? For example, I would want to wrap a div around content starting at a H2 element and ending after an img element. The div should have custom classes assigned to them. Is there anyway to do this? I don't want to have to hard-code the div so that other people can easily edit the page content. Thanks!
Category: Web

How to get widget content in Wordpress based on it's ID?

I need to parse widget content based on it's ID. But a widget works like a function that pulls data based on it's arguments, right? So when I pull the widget data, I can only get it's arguments, not the actual output. How can I parse the widget content based on it's ID? Example code: // Update widget rounds automatically function automatize_games_rounds($instance, $widget, $args){ // Check if there is a caption if (isset($instance['caption']) && !empty($instance['caption'])) { // If there is, …
Category: Web

how load content as pop-up using ajax

There's a way to use ajax to load the content from single.php or a custom .php like ajax-single.php like this page does it: https://yellowimages.com/all/objects/apparel-mockups/ also like them show the URL from the post when you click on the link, I hope somebody can help me with this because I can't find a way to do it yet. EDIT 1: I use the next code on my index.php to load the post titles with the permalink: <div id="single-post-container"></div> <div class="wrap"> <?php …
Category: Web

Remove tinyMCE from admin and replace with textarea

I have created a plugin wherein I have a custom post type. I am using post_content for some simple text. I do not need to offer any fancy editing or insertion of data for this field, so I looked for a way to remove the buttons from the tinyMCE editor. I never found a very good solution so I removed the editor from the custom post type supports in the register function. 'supports' => array('title','revisions','thumbnail'), Then to create an area …
Category: Web

Split content into multiple columns using more tag?

First of, this is pretty much an exact duplicate of: Split columns into three+ divs? But the given solution does not work (returns blank). I'm guessing it collides with qTranslate which adds some really weird comments to the html, but i'm not sure. I found a great code snippet that simply splits the content into pieces by the more tag. The problem is it seems to only split into two columns. It ignores the rest of the more tags. I …
Category: Web

Automatically search and replace link in content (pages/posts)?

The users of my site mainly share documents by inserting links into content (pages/posts) using the built in editor. These files include everything from pdfs to word documents. The users currently get/copy these links from a php file manager like FileRun. My goal is to have the users instead use a path from mapped network drive such as \testdrive\Folder1\Folder2\test.txt. The following function has been written to handle replacing the mapped network drive files to an internet link such as "http://page.test.org/files/". …
Category: Web

All files being pulled from wp-content returning 404 error

I am on a fresh install of Wordpress on Ubuntu / LAMP, and noticed that none of my site's images are showing. I tried to install a theme (Sydney) and none of the images were showing up. I was able to fix this by manually installing the theme to the wp-content directory. You can see in the image below that all of the files being requested from wp-content are returning 404 errors. I tried uploading images, but they are returning …
Category: Web

Add the same content to multiple pages

I have a website with over 500 pages. Dont ask why but none of these pages have any content in them. I have created a page layout to be added as a single wp bakery block and want to add this same block to all pages but I cant see a way of doing this without going through everypage and doing it manually. Am I missing something?
Category: Web

404/500 error on content images if Referer header is from another domain

Not very familiar with WordPress so I'm not sure what's causing this. Essentially, we have a few image assets stored under wp-content. When we access some assets (i.e. cmssubdomain.apex.com/wp-content/image.png) we are getting some peculiar behavior around the Referer request header: It works if accessed without the Referer header It works if accessed with the Referer header as long as the value matches the cms subdomain It fails once the Referer header is set to a value different than the subdomain …
Category: Web

WordPress Subcategory Creates 2 urls for same page (serious issue)

All subcategories in WordPress create 2 urls to same page. domain.com/parentcat/childcat/ domain.com/childcat/ both urls go to the same page. in the eyes of Google this is duplicate content. it seems it would be logical for WordPress to redirect domain.com/childcat/ to domain.com/parentcat/childcat/ Using WordPress 4.3 no plugins. I can't seem to find a fix for this anywhere. Any help would be appreciated.
Category: Web

Create dynamic content from one WP page to multiple other pages

I want to create dynamic content that is taken from a specific paragraph from one page and writes to a paragraph on multiple pages that feature that same content. I am new to PHP and not sure how to make this happen in WordPress. I have an existing WordPress webpage, let's call it the Plan, with paragraphs on it. The content of these paragraphs changes from time to time. The content in the Plan paragraphs is also on other existing …
Category: Web

Dynamic content based on a URL parameter

So, I'm doing some wordpress development studies and classes, and now I got an project to work on, and need to get the following task done: I'm doing a telecom website. The site has a page called "Buy" with its custom template. The ideia is that all other pages of services are linking to this page. I want this page to handle all service "order" requests from users. So it would look like this: www.example.com/buy/ And let's say, the user …
Category: Web

Remove Content Filter

I need help with removing the Content Filter from a Plugin: add_filter( 'the_content', array( &$this, 'addContentAds' ), 8 ); Do someone could help me please? Thank you and best regards
Category: Web

About

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