Visual composer Masonry grid doesn't load - php

I'm using [insert_php] plugin in Wordpress and I have inserted php function in it.If I set the block with the function before the the masonry grid it doesn't load.
If I move the block with the function after the grid it works well.
In console log is appearing an alert:
Syntax error, unrecognized expression: {'status':'Nothing found'}
How can I sole that?
Grid before php block
Block php before the grid

What you need to do is create a page template. This page template can be used to create PHP for your page to load, and you can even use
<?php echo do_shortcode('[shortcode]'); ?>
To create a template just copy your page.php into a new file called tpl_test.php.
Then make sure to have this in the very first line:
`<?php
/*
Template Name: Test Template
*/
?>`
Then, a small window will show up on the back-end of WordPress when you edit the page. In the right hand column you need to select the page template for the page you just created, and update the page. then, any code you put in the custom Page Template will display correctly on your WordPress site. Also, make sure <?php the_content() ?> is below your grid you are trying to output.

Related

How to add plugins to my custom wordpress theme?

I'm making a WordPress theme by myself since I'm working for the first time in Wordpress I've watched some tutorials about it.
I have page.php header and footer and ofc an index. I insert the content from the pages with this:
<?php echo get_post_field('post_content', $post->ID); ?>
but I tried the get_post in a while loop with same result..
Everything is fine but when I want to use a plugin I can't add to my page... When I insert the shortcode of it it shows only the shortcode string... There are some plugins where I can click a "view" option and it would show a page with my plugin (for example a calendar) but that page is empty...
When I activate an original theme it works instantly... So I'm sure something is missing from my theme something which can load the plugins but I couldn't find solution for it.
Any ideas?
Did you add the <?php wp_head(); ?> function before the head area of the html document is closing? It imports important scripts and styles from wordpress itself (and probably also from the plugins).
See here:
https://developer.wordpress.org/reference/functions/wp_head/
Before closing the body area, the template should also include
<?php wp_footer();?>
See here:
https://developer.wordpress.org/reference/functions/wp_footer/

Wordpress Adding Custom HTTP Header To One Template File

I need to add a header Access-Control-Allow-Origin: * into one of my template files. How would I do this I would like it to be for just this specific template so that its not site wide,
I think you're looking for is_page_template();
<?php
if(is_page_template('your-page-template.php')) { //Change this to the path to your wordpress template
//Add your code here...
} ?>
you can create a custom template page and call the custom Header on this template.
To create a page and apply a page template
use this code to create page template
First you need to have a single page. There are several ways to do it, one is to create a page in wordpress, then use the ID and create a file page-ID.php in the theme folder. Other way is to create a template file which you can select from the side menu in the wordpress editor.
In that page, you can add the php header and the code you want to show.

Wordpress Get URL Footer File

I need to access the footer inside a wordpress theme via a url. Ideally it would just render the footer data and nothing else, alternative suggestions welcomed though.
To add some context, the data will be fetched through the url and a script will read the markup. This data will then be cached and available through Magento where it is needed to be displayed..
Is there a url path that will display it or should I make a new page that can be called via the base-url+the-page-name???
There's nothing built in to do that. You could use the AJAX API in your theme or a plugin and accomplish it.
You hook into an action that gets sent as a URL or POST data parameter and then make a request to yoursite.com/path/to/wordpress/wp-admin/admin-ajax.php.
<?php
add_action('wp_ajax_so20495429_display_footer', 'so20495429_display_footer');
add_action('wp_ajax_nopriv_so20495429_display_footer', 'so20495429_display_footer');
function so20495429_display_footer()
{
get_footer('ajax');
}
This will work for all users, logged in or not, despite the wp-admin URL. Here is code above wrapped up in a plugin.
what you can do is make a wordpress custom page template.
If you dont know how heres a little tutorial : http://www.expand2web.com/blog/custom-page-template-wordpress/
Now you want the custom page template to only load the footer (add the html, head and body opening tags yourself)
if you create a new page with your page template seletced it will only output the footer.
Hope you can get it to work
Greetings
merijn
What about $footer_url=get_template_directory_uri().'/footer.php'; ?

Wordpress calling an HTML file from PHP

I am trying to modify a theme on wordpress. The theme shows a slider on the front page, which reads from the featured.php file.
I have gone into the featured.php and removed all the PHP code. I can inject my custom HTML into the featured.php and the pages display properly, however I want the page to display from a wordpress page.
So i tried to:
<?php
$html = file_get_contents('http://www.mydomain.com/homepage-featured');
?>
The above link corresponds to a page i created in wordpress. So i want to be able to inject my HTML into that page and then when you load my homepage, the PHP tells the browser to display the contents of this URL.
The above code doesn't work.
Thanks for the help.
file_get_contents() - as its name suggests - reads a file in but does not print it. You need to echo your $html variable. A better way is to use require() or include() but if I were you I would put my custom file on the same server so that way you don't have to use the file from a remote location thus sparing network traffic.
I think you have better to use the include function.
The file_get_contents you are using would generate an HTTP request, so it would make your script slower. I think it would be a good idea to put the HTML file on the same server if possible.
Have you tried
<?php
require('http://www.mydomain.com/homepage-featured');
?>
If my understanding is correct, you are trying to use a template (featured.php) for a different page other than the front page.
To do so, just change the Page Template of the page(the separate page which is # www.url.com/myhomepage). You can change this # Dashboard > Pages (Click Edit link in the required page) > Edit Page > Page Attributes meta box (available in the rightside below Publish) > Template. Change the template of this page to "Featured".
(I assume that your code in file feature.php has Template Name: Featured at the top)

add code snippet in magento core

I'm running magento 1.4 and I'm trying to display an overlayer banner on all the pages in my magento store. In which file should I add the code snippet for the banner so that the it gets displayed on all pages?
BTW: the code snippet is actually some a short php if function + an OpenX Javascript Tag
From this search:
Go to /admin/cms_block/ and add a block. Remember the identifier.
In your code add <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('identifier')->toHtml() ?>
There you go…
For javascript to be included on every page have a look at page.xml layout <default> section. For PHP code see which blocks are included on the page and create a block after (or before) one of them

Categories