Content Views issue when Cornerstone is activated

Hi, I’m having a conflict between Cornerstone and Content Views. When Cornerstone is inactive, the Content Views pages break off (as they should, and as they have until this week) at the manually-inserted “read more” break in the post. When Cornerstone is activated, however, the Content Views shows the whole post content rather than just the content before the “read more” break. For example, on my home page right now, the posts break at the read-more that was inserted in the post; if I were to activate Cornerstone, the whole post would show. I’ve replicated the problem on several of my other sites. I’ve contacted Content Views about this, but they are backed up. Perhaps you can find the issue. Thanks for your help.

site: savethepostoffice.com
WP: 5.2.4
X: 7.0.4
Cornerstone: 4.0.4

Also, when I deactivate Cornerstone and then inspect the page, I can see the read-more break at the appropriate place ( ), but it is not having any effect. The page just shows full posts anyway.

Hi Steve,

Thanks for reaching out.

It usually happens on plugins that checks existence of shortcode or string before it executes the code. And that plugin is probably not able to access the data of cornerstone.

Unfortunately, there is no workaround right now, the fix should be added to Content Views plugin and read cornerstone data instead of just reading the page content.

Thanks!

Thanks very much for looking into this. I’ll share your reply with Content Views.

You are most welcome!

Hi, I shared your reply with Content Views, and they replied with this: "We had troubles on reading Cornerstone data.
Might you ask them this question:

Is there any function to read Cornerstone data of a post/page by its ID?

We couldn’t find it in the last investigation on Cornerstone plugin."

Can you let me know what to tell them?

Thanks as always for your support.

Hi Steve,

It’s a post meta, it could be read with standard get_post_meta function. And the post meta name should be __cornerstone_data.

It can be also achieve by using shortcode finder API if they are using shortcodes. An example,

$finder = CS()->component('Shortcode_Finder'); $finder->has_shortcode('your_shortcode');

You can view an example at cornerstone\includes\classes\components\class-shortcode-finder.php for similar integration. But since it’s a 3rd party plugin, it should be using CS()->component() as their integration. An example assuming content_views_has_shortcode is content views filter for finding shortcodes, given it also pass $post object.

add_filter('content_views_has_shortcode', 'this_post_has_content_views');

function this_post_has_content_views ( $has_shortcode, $post ) {

$shortcode = 'content_views';
$finder = CS()->component('Shortcode_Finder');
$finder->process_content( $shortcode, $post->ID );

return $finder->has( $shortcode ) ? true : $has_shortcode;

}

This is just a sample and idea, each plugin could have their own standard depending on their hooks and options similar to how it’s implemented at class-shortcode-finder.php, hence, I can’t provide any exact recommendation. But the idea should be similar.

Thanks!

Well here’s what Content Views support says now:

Thank you for your reply.

Unfortunately that is not what we need.
It is not about checking if Cornerstone content has Content Views shortcode.

What we need is a function to get full content of a post, if it was built with Cornerstone.
(That is common question, doesn’t relate to our Content Views plugin)

Normally, a page builder plugin will add_filter to the_content, to process its shortcodes, then return the final content.
So Content Views can get full content easily by using the function the_content().
But from the last time we investigated Cornerstone plugin, the_content() doesn’t return content from Cornerstone.

Please send me support (at) contentviewspro.com a copy of latest Cornerstone plugin.
We will investigate again if that plugin changes their way.

Hey Steve,

I’m not familiar with the Content Views plugin but maybe what I’m about to show you might help with this investigation.

There are now 2 types of Cornerstone output. The Classic Elements and the V2 Elements. The Classic Elements’ Content is directly available in the Content Area.

When you use the_content() in a template, the More Tag in the Classic Text element will work. The V2 Text element though does not respect the More Tag so it will output full content. Below are screenshots of the output of Classic Text and V2 Text in the context of using the the_content() function.

Classic Text:

V2 Text:

Given all that, would you mind breaking your content using a Classic Text Element?

Regarding a function to read Cornerstone data, regretfully, we don’t have that yet.

If that doesn’t help, would you mind detailing your Content Views setup? Are you using the free version of Content Views? If you’re using the pro version, please make it available for us to download.

Also, save your post which was built with Cornerstone as at template and make it available for us to download.

Please just note that we can’t promise an immediate fix or an integration. We will just forward this to our development team because maybe they will be interested to investigate this case.

Thanks.

Hi Steve,

And as addition to Christian’s post, unfortunately, if they don’t need or wish to follow a plugin’s standard of integration then I’m afraid there is nothing we can do. It’s their plugin that needs the access to builder’s environment and what’s provided is to help them access what their plugin needed to access. If it’s just standard content like from an editor, then they can simply wait the output of the_content, but it’s not that simple.

Our builder is correctly following the_content standard, but since there is a complex structure then Content Views may not able to properly detect what it’s looking for within the content due to the hook/filter priorities.The builder handles page breaks automatically and that is to prevent it from breaking the layout instead of just the content. Example is this

`

Page 1 content `

Break here

`
Page 2 content>

`

As you can see, you cant put break in the middle as the closing </div> will be moved on the next page breaking everything. That’s why even if they don’t need it, they must still follow it to make sure it works seamlessly.

Thanks!

Thank you for all the work you’ve put into this issue. I’ve shared your latest replies with Content Views support. After I hear back, I’ll share the setup info and everything else with you. (Btw, I’m using Content Views Pro.)

I just want to clarify that the pages where the “read more” break is not working were not built with Cornerstone. This problem occurs on pages using Content Views simply when Cornerstone is activated. None of the pages on the site are made with Cornerstone. I hadn’t gotten to that yet, since I’m in the processing of switching the site to X.

Thanks for clarifying, Steve. In that case, it’s different than what the Content Views support needs (see this previous reply).

In that case, it could be related to the_content filters in Cornerstone. I checked them and I don’t see anything that could strip the Read More <!--more--> tag in the content though. That’s my guess why the content is shown completely skipping the Read More.

The closest filter that removes HTML is this:

    // Remove empty p and br HTML elements for legacy pages not using Cornerstone sections
    add_filter( 'the_content', array( $this, 'legacy_the_content') );

That’s just removing p and br tags though. It can be found in wp-content\plugins\cornerstone\includes\integrations\x-theme.php

You can find the other filters in these files.

wp-content\plugins\cornerstone\includes\classes\content\class-content-preview-frame.php
wp-content\plugins\cornerstone\includes\classes\common\class-front-end.php
wp-content\plugins\cornerstone\includes\classes\classic\builder\class-preview-window.php

That might help the Content Views developer get started in finding the conflict.

More from Content Views (before your most recent note):

As our plugin couldn’t get content from Cornerstone builder using standard the_content() function, we used some functions to get posts content built with that plugin.
These functions might ignore the more tag, that caused the issue you are having.

So the potential solution is disabling these functions.
(But the drawback can be: if you built post/page content with Cornerstone plugin, these content might not be shown in our grid)

To disabling these functions, Please add this code to file functions.php in the theme’s folder (or install this plugin Code Snippets then add this code to the “Code” textarea):

// Content Views - remove functions which get content from Cornerstone
remove_filter( ‘the_content’, ‘cv_comp_plugin_cornerstone_single’, PHP_INT_MAX );
remove_filter( ‘pt_cv_field_content_excerpt’, ‘cv_comp_plugin_cornerstone_core’, 9, 3 );
remove_filter( ‘pt_cv_field_content_full’, ‘cv_comp_plugin_cornerstone_core’, 9, 3 );

Hi Steve,

Thanks for sharing the possible solution, so it seems it’s their hooks that is causing the issue as none of that is cornerstone hooks.

I was also confused, as the_content hook is only applied if a page or post is built in cornerstone. So it shouldn’t affect the page or post not created by cornerstone.

I just want to clarify that the pages where the “read more” break is not working were not built with Cornerstone

Now they are saying their plugin couldn’t get the content from cornerstone builder using the standard the_content(). And it’s true since it needs proper integrations as provided above for it to access the data that is being processed within the_content().

If their integration is removing their hooks then it should be good too :slight_smile:

Thanks!

Content Views support had me add this to the functions.php and it worked perfectly. Thank you for all the time you put into this issue. I really appreciate it.

// Content Views - remove functions which get content from Cornerstone
remove_filter( ‘the_content’, ‘cv_comp_plugin_cornerstone_single’, PHP_INT_MAX );
remove_filter( ‘pt_cv_field_content_excerpt’, ‘cv_comp_plugin_cornerstone_core’, 9, 3 );
remove_filter( ‘pt_cv_field_content_full’, ‘cv_comp_plugin_cornerstone_core’, 9, 3 );

You’re welcome! And thanks for sharing this :slight_smile: Cheers!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.