I have page on wordpress site
http://upsourcemobileservices.com/solutions/
in footer.php I have added the following:
if(is_page('solutions')){
echo str_replace("The MVNi","The MVNi solution was created to ensure that wireless communications are available to the smaller Telco operators.","The MVNi");
}
but it is not changing the contents of the page.
To my knowledge, Syntax is correct str_replace(find,replace,string)
What am I doing wrong?
I also tried using jQuery
function replaceText(jQuery) {
$(".portfolio-thumbnail-content:nth-child(1)").replaceWith("<div class='portfolio-thumbnail-content'>The MVNi solution was created to ensure that wireless communications are available to the smaller Telco operators.</div>");
$(".portfolio-thumbnail-content:nth-child(2)").replaceWith("<div class='portfolio-thumbnail-content'>Primarily aimed at existing Telcos our MVNc solution integrates your existing platforms with ours through the use of APIs.</div>");
$(".portfolio-thumbnail-content:nth-child(3)").replaceWith("<div class='portfolio-thumbnail-content'>UMS turnkey solution is a complete MVNO in a box.</div>");
$(".portfolio-thumbnail-content:nth-child(4)").replaceWith("<div class='portfolio-thumbnail-content'>This solution allows you to select the products and services that you want and integrate them with your existing platforms.</div>");
}
$(document).ready(replaceText);
but can't seem to get that working either, here's a fiddle http://jsfiddle.net/vzy9R/3/
I used jQuery eq() selector to find elements containing class portfolio-thumbnail-content and then using .replaceWith() I was able to load my teaser content (excerpts) ending with complete sentences.
For example, the About page:
(function ($) {
$(".portfolio-thumbnail-content:eq(0)").replaceWith("<div class='portfolio-thumbail-content'>This is my new complete sentence teaser for Team.</div>");
$(".portfolio-thumbnail-content:eq(1)").replaceWith("<div class='portfolio-thumbail-content'>This is my new complete sentence teaser for Partners.</div>");
})(jQuery);
Then I had to figure out a way to implement those scripts into the body of those pages, so I wrote my own shortcodes and added them to functions.php
//[replaceTextAbout]
function replaceTextAbout_func( $atts ){
return "<script src='/javascript/custom/replaceText-About.js'></script>";
}
add_shortcode( 'replaceTextAbout', 'replaceTextAbout_func' );
Related
Wordpress | Advanced Custom Fields plugin
I created a new field in the editor where my colleagues can fill in a URL relevant to that specific page. This URL will be used in the button we load on every single job listing page. This button is created within the functions.php file:
function my_editor_content( $content ) {
$content = "<h3>Title</h3><p>text</P>
<a href='[acf field='afas_url']' target='_blank' rel='noopener'><button>Solliciteer Nu</button></a>";
The above is cut off at the 'afas_url' part. So, I think it has something to do with the quotations marks and probably not even hard to fix, but as I'm just starting to figure things out I couldn't find the answer myself yet.
I hope it's a clear enough explanation :)
(And maybe it's not best practice to use functions.php but it was already like this)
After digging internet for an answer I cannot find any idea about how to deal with my issue. I think the problem is common for someone who knows PHP a little bit.
To describe the situation. For some custom WordPress plugin I've got two PHP files: ff_config.php and loantest_form.php. First file contains some configurations of plugin plus following lines:
/**--------------------------TABLE SHORTCODES-----------------------*/
function render_loantest_form() {
include(plugin_dir_path(__FILE__) . 'front/loantest_form.php');
}
add_shortcode( 'render_loantest_form' , render_loantest_form );
/**--------------------------DISPLAY PLUGIN IN FOOTER-----------------------*/
add_action('wp_footer', 'display_loantest');
function display_loantest() {
echo render_loantest_form();
}
Which I suppose rendering second file containing enqueue scripts (js/css) and whole HTML output and placing in wp_footer where it exactly is on my page.
The question is: how to change mentioned lines to allow me to place render result (loantest_form.php) in specific div / id on page (for example #sidebar-slider)?
If you want to display your shortcode in a template file,
echo do_shortcode('[render_loantest_form]');
Enable the use of shortcodes in text widgets.
add_filter( 'widget_text', 'do_shortcode' );
And inside the text editor
[render_loantest_form]
You can read more about do_shortcode()
Note that you need to be sure that the file load in the render function is good and that it returns the expect content.
I recently followed this post on integrating FullPage.js as a WordPress plugin.
I'm having trouble getting the plugin to work with other plugins - such as "All in one Event Calendar". The calendar works it just won't display on pages using FullPage.js
I understand the limitations that a plugin meant for landing pages has, but I was wondering if there was any way to edit the existing FP plugin template so that it can utilize other plugins while also taking over the theme's template?
Perhaps editing this statement?:
function fullpage_template( $original_template ) {
if ( get_post_meta( get_the_ID(), 'fullpage_js', true ) ) {
return dirname(__FILE__) . '/templates/fullpage.php';
} else {
return $original_template;
}
}
I really appreciate any assistance on this!
You might be having problems because you are using verticalCentred:true or scrollOverflow:true.
As said in the fullpage.js FAQs
My other plugins don't work when using fullPage.js
Short answer: initialize them in the afterRender callback of fullPage.js.
Explanation: if you are using options such as verticalCentered:true or overflowScroll:true of fullPage.js, your content will be wrapped inside other elements changing its position in the DOM structure of the site. This way, your content would be consider as "dynamically added content" and most plugins need the content to be originally on the site to perform their tasks. Using the afterRender callback to initialize your plugins, fullPage.js makes sure to initialize them only when fullPage.js has stopped changing the DOM structure of the site.
In my ecommerce store I have a "checkout process" that consist of 3/4 pages. I want to run an experiment on this (A/B testing) with Google Analytics. Specifically; I want to try a different stylesheet that hides a couple of elements (display:none;) to make the checkout more simplistic.
Basically I want Google Analytics to use global.css for the "original" page and global_b.css for the "variant".
Making different variants for every page is not the ideal solution. In the documentation there is a soluton but I don't really understand how to implement this: https://developers.google.com/analytics/solutions/experiments-client-side#implement-choose.
How do I modify the given script to only work for the pages I want to test (e.g. checkout_1.php, checkout_2.php, checkout_3.php) and switch between the two stylesheets?
The way I've approached this is to
1) Add an additional CSS class definition to global.css :
.ga-experiment-no-display{
display:none;
}
2) Add an additional html class to each element that can be hidden on checkout_1|2|3.php, such as '.ga-experiment'
3) The Checkout pages each loads the GA experiment code and includes a JS file (checkout.js). This has code that:
var chosenVariation = cxApi.chooseVariation();
if (chosenVariation > 0){
//Search for all elements with $('.ga-experiment')
//Add the class '.ga-experiment-no-display'
}
How can I place a default text (hashtag) in the Custom Message?
The textarea is (located in line 643) under jetpack/modules/publicize/ui.php
I tried to put the text in front of $title in various ways, like:
<?php echo "#myhashtag $title"; ?>
or
<?php echo '#myhashtag '.$title; ?>
but it just echoes the text, not the $title.
Any ideas will be greatly appreciated.
You can use the approach of this Wordpress plugin i made (Publicize With Hashtags), which does exactly that. It basically use and action trigger bound to the 'save_post' native event.
If you want to develop your own one you can have a look at my Source Code on the project's GitHub page or in this installation & usage guide I wrote about it.
You can add a filter, like so, to your theme's functions.php or a site-specific plugin:
add_filter( 'wpas_default_prefix', 'add_default_publicize_hashtag_prefix', 10, 4 );
function add_default_publicize_hashtag_prefix() {
$default_tags = '#yourhastaghere ';
return $default_tags;
}
This will add your default hashtag before your title without you needing to hack the WordPress core.
jetpack/modules/publicize/ui.php itself states in its comments:
/**
* Only user facing pieces of Publicize are found here.
*/
You added your hashtag in the textarea which allows admins to enter a custom message (click edit and it will slide down with your hashtag).
As #Yazmin mentioned, the best way to permanently edit the message is using a filter. The filters available are wpas_default_prefix, wpas_default_message, and wpas_default_suffix.
Personally, I had no success using these filters and I'm interested in a working solution to this issue myself.