Tag Info

New answers tagged

2

It will be bit tricky to detect if user just get into site. But generally there will be no referer, hence wp_get_referer() will return false. My code check if there is referer, if no then they get redirected to post page. NOTE: When user access a page in admin by typying url in adressbar then redirect is applied to them also, because there are no ...


0

To all of you struggling to get custom scripts running from functions.php, here's how: WP v4.1.2 Th post is a custom template post I needed to load 3 JSs - parsleyjs.js, he.js (i18n), custom_JsScript.js I also wanted to have the CSS on a separate file Only load these for a specific post function donate_adding_scripts() { if (is_singular()) { global ...


3

You can set the expire date as post meta value. In single.php you can easily show that date by querying the post meta. See update_post_meta() and get_post_meta() Now, the second part of your question is pretty tricky. I can think of 2 solutions. Cron You can use wordpress cron to run at a time interval to check which post has been expired and ...


0

What if you completely remove the loadDonateScripts function and just add the conditional before enqueuing the scripts like in the the following: function donate_adding_scripts() { if (is_single()) { global $post; if($post->ID=="8436"){ // only for post Id = 8436 wp_register_script('donateParsleyJs', get_template_directory_uri() . ...


0

You can check to see if the length of the excerpt is longer than the max count. if(strlen($excerpt) > $count){ $excerpt = substr($excerpt, 0, $count) . '…'; } … is the correct ellipsis character to use.


0

Look into using add_query_arg() (documented here) to attach the query parameter(s) to the URL. This (below) is untested, and there is probably a nicer way to get $baseUrl, but hopefully this example will point you in the right direction. function wprdcv_param_redirect(){ if( !is_admin() ){ $baseUrl = "http://" . $_SERVER['SERVER_NAME'] . ...


1

jQuery is already loaded with WordPress, so you won't need <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> When using jQuery with WordPress, you'll likely require no-conflict wrappers : https://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_Wrappers There are likely JS errors ...


5

You can use get_the_title() to return the current post title in the loop.


0

I think the problem is with your choice of hook and conditional statement. Try init and remove the !. function themeblvd_disable_admin_bar() { if( current_user_can('edit_posts') ) add_filter('show_admin_bar', '__return_false'); } add_action( 'init', 'themeblvd_disable_admin_bar' ); Looks like your conditional is also wrong for the redirect ...


0

It is possible as referenced here but you are talking about a great deal of customization in the Gravity forms plugin and like you said you are not a programmer yourself, so you better open a support ticket in their forums and they might be able to help. Also look at this code that can help you if you decide to do it yourself $upload_dir = ...


0

set the product image upload in fullsize then add the code below in functions.php add_image_size( 'thumbnail', 150, 150, array( 'center', 'top' ) );


2

You have the following methods of the $wpdb object: $wpdb->flush() that contains a call to mysqli_free_result() or mysql_free_result() if not supported. $wpdb->check_connection() that contains a call to mysqli_ping() or mysql_ping() if not supported. You can of course use all your PHP functions in WordPress. Here's an example based on the \wpdb ...


0

Try the following: Replace your current upload filter with the one below Create a new custom post and upload some files Check the files have been moved to the correct uploads folder Delete the custom post and then check the files have been deleted New uploads filter function: function set_upload_dir( $args ) { if ( ! empty( $_REQUEST['post_id'] ) ...


1

you can try a code like this <?php function theme_settings_init(){ register_setting( 'theme_settings', 'theme_settings' ); } ├« This is used to reserve a name for a custom settings array //Add settings to page menu function add_settings_page() { add_menu_page( __( 'Contenu ├ęditable' ), __( 'Contenu ├ęditable' ), 'manage_options', 'settings', ...


1

In your source you allow only the selector tag p for the class - 'selector' => 'p',. You find a longer answer with examples in this WPSE-Question. I think is not helpful to share the same content here in this question.


0

Why don't you create a specific template just for embedding? In your custom template, you could just remove the get_header(), get_footer() and get_sidebar() calls. http://codex.wordpress.org/Page_Templates#Custom_Page_Template


0

What you are describing sounds like a typical CRUD app. It is certainly a possibility with WordPress (many things are), but natively it is tuned to working with content rather than forms and data. There probably will be a curve, learning to bend it for CRUD, you might not want to deal with. From the things you named: forms: WP has some elaborate forms on ...


0

This may not be the exact answer to the problem. But it helped me to solved the very problem we are discussing. As using 'transport' => 'postMessage', I was not able to see previews lively. So I created new files using the following code at Github I just copy pasted this code. Verified it and then tweaked it according to my requirements. I know this is ...


0

I just found this question when looking for a function to create a dynamic countdown and I guess AJAX is the solution for me. I modified some code I found on a website (do not remember which one) and I'll post it here with the hope it will be useful to somebody. Here's the code: date_default_timezone_set('America/Mexico_City'); //For some reason I needed ...


0

I actually already have an open source plugin that does this already: https://github.com/tripflex/wp-login-flow It was created to require users to verify their emails but you can disable that feature and just use the rewrite feature which is functional in the latest version on WordPress repo (1.0.0). You can look at the code to see how I handle the ...


0

I ended up using a GET method and got rid of add_query_arg() function $homezip = $_GET["search"]; <form action="local-concert-listings/" method="get"> <input id="address" size="6" type="text" placeholder="Zipcode" name="zipcode"/> <div style="display:none;"> <input id="volume" size="1" name="miles" value="70" ...


0

There are multiple ways to go about this, but one way I would consider if I were you would be to do it like this. On the index.php or whatever page the posts appear on do the following three times each with different categories: $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $arguments = array( 'category_name' => 'category' ...


1

I understand, that you add the possibilties for developers to change the html, typical a template part. That is the point, that I think you should use the default functionality for this job. get_page_template() can be overridden via the page_template filter. A simple example for the dev to change your templates from your plugin. add_filter( ...


1

You cannot insert the do_action() inside the class like that, it's gonna give you a fatal error. Instead you could use an array $skins to store all the skin functions (as closures), and the magic method _call() to call them: class skinclass { private $skins = array(); function __construct() { $this->skins = apply_filters( 'add_skin', ...


0

Figured it out. I had to re-read the codex a lot to figure out that when you pass an array to update_post_meta it is serialized. By using maybe_unserialize() on the return value I was able to to get access to the values. Hope this helps some future searcher!


3

What about using the WordPress function get_ancestors(), which Returns an array containing the parents of the given object. To be exact an Array of ancestors from lowest to highest in the hierarchy We can easily create a function to return a list by using implode to do so: function wpse185971_get_ancestors_list( $object_id, ...


2

get_template_directory() returns a filesystem path-- that is, it returns the path to the file as it would appear if you were browsing it on the local machine via a file browser. Return Values (string) Absolute path to the directory of the current theme (without the trailing slash). ...


1

If I had to guess, I'd say you're running into a memory leak like you suggested, infinite recursive loop. You need to run checks for when the term either hits the top of the ancestry tree or errors out: $ancestors = $terms[0]->term_id.GetAncestors( $terms[0]->term_id, $include ); function GetAncestors( $term_id, &$include ) { $child_term ...


1

The $multipage is constructed inside the setup_postdata() method of WP_Query. It's called when you run the_post(). So just as @s_ha_dum explained, you have to make a loop around it: You can try this: if( have_posts() ) { the_post(); // Make a call to setup_postdata(). echo sbwp_get_current_chapter(); // Display the current ...


2

$multipage is an "inside the Loop" variable. I did not track down exactly where and how it is set but given that information alone the obvious solution is to put your code inside a Loop, which is good practice anyway as a number of things depend upon that Loop. Something like: if (have_posts()) { while (have_posts() { the_post(); ...


0

Unsure of WP version compatibility, but taken from the Soil plugin module clean-up.php for Roots. Use in your theme's functions.php or similar. function clean_script_tag($input) { $input = str_replace("type='text/javascript' ", '', $input); return str_replace("'", '"', $input); } add_filter('script_loader_tag', 'clean_script_tag');


0

This is pretty easy out of the box: Just use the [_url] special mail tag. As long as you are on a post or page you can even add some more things like the title with [_post_title]. Just have a look at the documentation for more options.


0

You can try to add a get parameter to your url in the link to your contact form. If it's a lightbox style, you can also define a hidden field and fill it when wpcf7 loads up using global $post. Use this code for the url parameter solution and replace id_post by global $post->ID for the lightbow solution : //Add the post id function add_post_id_origin ( ...


0

SOLVED: can't figure out the best way to update my question, sorry! Thank you Rarst the link you provided helped me figure this out: add_action('wp_enqueue_scripts', 'watercolor_js_scripts'); function watercolor_js_scripts(){ if (!is_admin()) { wp_register_script('cycle2', get_template_directory_uri() . '/js/cycle2.js', array('jquery'), ...


1

Use wp_register_script & wp_enqueue_script to enqueue the scripts the right way. add_action( 'wp_enqueue_scripts', 'enqueue_my_script' ); function enqueue_my_script() { wp_register_script( 'my-script', get_template_directory_uri() . '/cycle2.js', array( 'jquery' ) ); wp_register_script( 'enq-jquery', ...


1

Your snippet seems mostly ok, except that dependency is a list and should be array('jquery'). Also wp_enqueue_scripts should be use as more appropriate. You can check out Codex documentation for a complete example, see Example of Automatic Dependency Loading.


0

I think you need to do the add_action( 'wp_head', 'add_meta_tags' , 10 ); in your functions.php instead of the template to get the function called. And it adds it then everywhere where you have wp_head(). So if you want to only call it content-share.php you need some conditioning logic like if (is_page_template('page-templates/content-share.php')) { ...


0

You don't have to set that code in your functions.php. Naming a file single-press.php should do the trick if you named well you custom post type when you declared it. The post type should continue to use single.php. I this doesn't work, please provide wp version and custom post type declaration.


0

Your problem is with the conditional, not with the used action (I think). This line is probably not verifying in any situation: if( ( $_POST['post_status'] == 'publish' ) && ( $goalsupport === $totalsupport ) ) { I can not now what $goalsupport and $goalsupport are, both variables are undefined in your code, so I'm going to remove them. Change ...


0

You can just list them as a list regularly, and style them with css li:nth-child(even) { background: #000 } li:nth-child(odd) { background: #CCC } If you are worried about browser support you could add different classes when you're populating the list in PHP using $i or something like for($i = 0; $i < count($list); $i++) { echo '<li class="'.($i ...


0

First of all you have to start log views of each post. You can do it by yourself or by a plugin. Here you have an example how you can track this number without any plugin. Add this code to the theme's functions.php file function prefix_get_post_views( $post_id ){ $count_key = 'post_views_count'; $count = get_post_meta( $post_id, $count_key, true ); ...


0

You're not handling the names the same way as the other fields: //// VERIFIES CREDENTIALS $username = isset($_POST['username']) ? trim($_POST['username']) : ''; $first_name = isset($fields['user_first_name']) ? sanitize_text_field(trim($fields['user_first_name'])) : ''; $last_name = isset($fields['user_last_name']) ? ...



Top 50 recent answers are included