Tag Info

New answers tagged

0

Replace: $l = ' | Theme Designed by: <?php echo wp_theme_credits(0); ?> | Thanks to <?php echo wp_theme_credits(1); ?>, <?php echo wp_theme_credits(2); ?> and <?php echo wp_theme_credits(3); ?>'; With: $l = ' | Theme Designed by: <?php echo wp_theme_credits(0); ?>';


0

I think you should use post-thumbnails In your functions.php file This function will give you access to add image on each post you want to add am image //And post featured images function add_featured_image(){ add_theme_support('post-thumbnails'); } add_action("after_setup_theme", "add_featured_image"); After adding that function in your ...


0

I ended up just rewriting the function. In case anyone ever comes across this, this is what I wrote. Cheers WPSE! add_action( 'wp_loaded', 'wc_custom_add_to_cart', 99 ); function wc_custom_add_to_cart( $product ) { if (is_admin()) { return; } $cart = WC()->cart->get_cart(); $products_to_check = ...


1

Is there a way into making Wordpress think that the Google mail servers are local mail servers so that phpmail can be used properly? Yes, you could use a firewall to create a localhost:465 socket that forwards network traffic to smtp.gmail.com:465 but what on earth for?? Is there an alternative solutions? Yes, and you're half way there with ...


1

This: $thm_out[array_rand($thm_out, 2)] is the same as $them_out[array(0,2)] where 0 and 2 are 2 random keys. See array_rand I hope you can see what is wrong there. Change that to: $thm_out[array_rand($thm_out, 1)] which is the same as $them_out[2] where 2 is any random key.


0

You could use wp_schedule_event to schedule recurring tasks. The smallest precision it normally supports is "hourly" but you can use wp_get_schedules to create a custom "ten_minutes" interval. Or, you could use wp_schedule_single_event to just trigger the event once and have that scheduled task schedule the next event ten minutes later.


0

To display users with specific ID's on a page you'll need to run a WP_User_Query, either by placing the following code in your functions.php and calling it with a shortcode or adding it to the page template: //Replace the numbers 1, 2 with the user ID's to return $args = array( 'include' => array( 1, 2 ) ); // The Query $user_query = new ...


0

I'm not sure how the error message is being displayed for any number, as throughout most of the script you use the alternative structure for if statements and foreach statements (using : instead of {}) then at the bottom you mix in an if(){} inside an if : endif which is not allowed, see here for more info: ...


1

My solution to this problem when extending the Walker_Nav_Menu was to skip check if current_page_parent when C.P.T. I identified C.P.Ts following this stackexchange post. This does not entirely solve the problem as I am using current_page_item for C.P.T parent menu items, but it does achieve the desired outcome. Here is my class. class My_Menu extends ...


0

EDIT - OK replace the line with: echo "Shipping " . get_vendor($index + 1);


2

As this is an AJAX function your function must exit; or die(); after the final line of executed code, in this case outside of the if statement before the final } However I don't think this is the true issue, if you are getting a 0 returned in my experience it means the function is not running because admin-ajax.php returns 0 if it hits the end of the file ...


0

You might want to check : https://wordpress.org/plugins/tabsy/ . I'm using similar shortcode layout. I hope this helps. Thanks! Cheers, phpbits


0

Some of the code you have in here is really outdated and has been deprecated for quite some time. I am going to use updated code so that it's more useful to those who will stumble on this thread. <div class='news_item'> <?php $posts = get_posts( 'numberposts=2&order=DESC&orderby=post_title&category_name=news' ); ...


0

The function for showing the featured image is http://codex.wordpress.org/Post_Thumbnails To show your content in columns best way would be to wrap your content in a html element then float it. eg. In your template you might have: <?php $posts = get_posts('numberposts=2&order=DESC&orderby=post_title&category_name=news' ); foreach ( ...


1

Couldn't find anything built in to WP to do this, but there's a good tutorial on this site for setting something up like this: This does not support custom format so I recommend using the original post function http://www.renegadetechconsulting.com/tutorials/jquery-datepicker-and-wordpress-i18n You can also find a Gist of the code here: ...


0

If you're in the single custom post template, you can get the terms that the post belongs to by use of $terms = get_the_terms( get_the_ID(), 'btp_work_category' ); Then you need to determine parent term and display it with its children. The code below assumes that the post belongs to one top category (term) and the taxonomy tree has no more than 2 ...


1

First of all, some recommended reading - AJAX in Plugins. I realise this is not a plugin, but the Codex is still relevant, and as you'll see in the PHP section, you can use the WP AJAX handler to handle front end calls as well as those from the admin area. Javascript For this, you would be better advised putting your JS in an external *.js file that is ...


1

For anyone else having this issue - the working code looks like this (placed in the functions.php file): function default_post_type($post_id) { if (in_category('YouTube')) { set_post_format($post_id, 'video'); } } add_action( 'publish_post', 'default_post_type' ); Happy WordPressing


0

I'm also wanting the post to be assigned the post type "Video". You can't just change a post to a different Post Type. There is a difference between "Post Type" and "Post Format". From your examples I assume you would like to change the "Post Format", as per the codex http://codex.wordpress.org/Function_Reference/set_post_format, you would need to ...


0

According to the get_post_meta() function reference in the WordPress Codex, "If there is nothing to return the function will return an empty array unless $single has been set to true, in which case an empty string is returned." That means we can use ternary operators to check whether get_post_meta() returns an empty string, and if so then we assign the ...


0

ave you tried to put it in the Shortcode-function? I would suggest this: function my_shortcode() { ?> <script> alert('test') </script> <?php } add_shortcode( 'my_shortcode', 'my_shortcode');


0

In the DB, the wp_user_roles option in wp_options was empty. I copied the value from the same option in wp_2_options, as I had already added another blog. Also, every user from the original blog (it was up and running before being changed to a network) had nothing listed against both the wp_capabilities and wp_user_level options in wp_usermeta. Because of ...


1

What would you do if the user uses a proxy and randomizes his IP address? There are numerous browser plugins to simplify that to a click of a button to download multiple times. The same goes for cookies. Aside from that you are trying to collect data that allows to identify users, which is illegal in lots of countries. What (could) work much better is a ...


2

You don't specify where exactly the error comes from but I assume your problem is that you assign an object to the slug instead of a string. your code should look like $t = array_shift( $terms ); $params['slug'] = $t->slug;


0

If I understand your question correctly, you should be able to grab the information you're after from $the_user. If you use: $my_post['post_content'] = print_r($the_user,true); you should be able to see all the available user information in the page. Once you know exactly what you want, you can echo it out nicely with something like: ...


0

I manage to use the function but still not working properly function btn_play_index($content) { $btnplayindex = $content; $btnplayindexpattern ='#data-playlist="([0-9]+)"#isU'; $btnplayindex = '<a href="#"><img class="fap-add-playlist posts-playlists-btn-player" data-enqueue="no" ...


0

You are using add_action on init hook, instead of add_filter on the_content hook. Actions (functions triggered by add_action) are not expected to return anything. You use filters (add_filter) for that. In your case, you need to replace this: add_action( 'init', 'btn_play_index'); with this: add_filter( 'the_content', 'btn_play_index' );


0

You need the do_shortcode() function <?php echo do_shortcode("[contact-form-7 id="54" title="Contact form 1"]"); ?> I have not tested your shortcode.


1

If you only want The Content (of the main editor of the post) displayed, you can use echo get_the_content(the_ID). If you want more: First, you have to get the post data from the database, with the function get_post, or doing a query with WP_query. Then you can output different parts like title, date, content... accessing your variable properties, or doing ...


0

I think that when you are filtering, you are using an onpage action that hides what is not on the category clicked (done with JavaScript, usually with jQuery), and when you go to another page, you are getting a new page from the server, so your filter disappear. I think that this behaviour is ok, and to acomplish what you expect, you need to implement a ...


0

I think you have to set the slug value to an empty string like '', deleting item. I think that @kaiser think that item is a generic string for the posts, and he suggest to not prepend that string to your custom post type permalink. That's a good idea. But item is the slug for the CPT, so that's why is not working


1

If you edit plugin files and cause the plugin to trigger an error, it will deactivate the plugin. It doesn't do any sort of caching of plugin files, not sure where you're getting that info. To reactivate the plugin, you just have to go back to the plugins page and reactivate the plugin. Of course, if you don't fix the error you created, it's not going to ...


1

You arent clear where you want your else statement, so Ive added one for each of the if's you included. <?php $post_type = 'post'; // <-- Post Type $tax = 'temporada'; // <-- Taxonomía $termino = get_terms($tax); $category = get_the_category(); $cat_name = $category[0]->cat_ID; if ($termino) { foreach ($termino ...


0

It’s just that you got it a bit wrong - it’s actually if(is_single()) (not singular). If you want to address pages in general (not posts I assume), you would use if(is_page()) . If you need to address a specific page you could use its ID like so if(is_page(13)) where 13 would be the ID of the page. But you have a lot of options - see ...


1

Two options. The first will keep you away from custom SQL, and should be a lot more efficient than what you currently have. It runs two queries, one to get the user ID with the highest hourly rate, and then again to get the lowest. You need one more query to update the user meta cache & then you're home free: $query = new WP_User_Query; $users = array( ...


1

You can include wp-load.php (in the root Wordpress directory). This will give you access to the Wordpress functions. Note that you can also load wp-blog-header.php, it loads wp-load.php eventually; wp-load will be lighter weight in the end.


2

the_title() calls your function again. If you want to avoid that, remove the callback inside of your function: function filter_title_after() { remove_filter( current_filter(), __FUNCTION__ ); // the rest of your code. But you shouldn’t call the_title() in your function at all: it prints the title – this is not what you want – and you get the ...


-1

I have a not "so better", but a solution. I've tried with your method with the following setup: Localhost, Using ISS Wordpress version 4.1 and to get the right url I changed the wp-config.php and added this line: define('WP_DEBUG', false); define('MULTISITE', true); define('SUBDOMAIN_INSTALL', false); define('DOMAIN_CURRENT_SITE', 'localhost'); ...


0

Here is the solution I came up with using options. Thanks for the advice this worked well for my use case. <?php // This function sends the http request that purges my cdn cache. function hw_cdn_purge() { // My http request code goes here. // After the request the purgeCdnResult variable is set to the status code of the http request. I will demo that ...


-1

$string="jomon is name my"; for($i=strlen($string);$i>=0;$i--) { $char.=$string{$i}; } echo $char."<br/>"; for($i=0; $i<strlen($char);$i++) { if($char[$i+1]==" " || $char[$i+1]=="") { for($temp=$i; $temp>=0 && $char[$temp]!=' '; $temp--) echo $char[$temp]; } echo " "; } ?>


0

When the query was done using ~ (tilda) quotes around columns in the SQL instead of the ' it worked. It has something to do with the collation of my tables in MySQL, I believe.


1

Your function does not have to accept all arguments, you can not specify the number of accepted arguments and it will default to passing just the first. You can also specify any number up to and including the total number of arguments. For example if you only need the first 2, this will also work: function my_filter_func( $redirect_to, ...


0

Add a conditional to the existing if-statement checking for is_front_page() (or is_home(), depending on your needs): if ( ! empty( $image ) && is_front_page() ) {


3

From the Codex If you are using a custom homepage with custom loops and stuff or a custom front-page, you will have an empty wp_title. Here goes a neat hack to add the description/tagline at the wp_title place on homepage: add_filter( 'wp_title', 'baw_hack_wp_title_for_home' ); function baw_hack_wp_title_for_home( $title ) { if( empty( $title ) ...


0

The problem you are seeing is that you have your declarations of the same importance from a CSS standpoint. If you add another style to give it more preference: #cqrm-current-item-list tr.cue-deletion.cue-coming-soon, #cqrm-current-item-list tr.cue-deletion.tr.cue-coming-soon *{ background-color: #fbb !important; filter: alpha(opacity=100) !important; } ...


0

I found the errors thanks to the help from @Milo @Milo's query on catno pointed me to my error with my first query involving catno, and I also noticed a double equals in $catno == $row[0]; when it should be $catno = $row[0]; Final coding is function QueryStock($cat) { $query = "SELECT * FROM stock WHERE catno = '$cat'"; global $wpdb; $row = ...


6

It looks like your site's title is empty. Fill it out or try for example: add_filter( 'wp_title', function( $title ) { return trim( $title ); } ); to remove the blank space in front. For your setup, the following part of wp_title() is responsible for the blank space: $title = $prefix . implode( " $sep ", $title_array ); So when you're on a single ...


1

Simply add an extra line before your for loop. For example: function get_color_dropdown($taxonomies, $args){ $myterms = get_terms($taxonomies, $args); $output ="<select onChange='window.location.href=this.value'>"; $output .= "<option value='default'>Shop by Color --></option>"; foreach($myterms as $term){ ...


0

I'm not sure I fully understand what you're trying to achieve, but I'd suggested to attempt to construct the field's ID and name from data you've got available from the source code of the generated widget. If you check out the code, you'll find that by every widget, there's a hidden form field called id_base and widget-id - this should be enough to figure ...


0

Add timezone offset to your timestamp. $offset = get_option( 'gmt_offset' ) * HOUR_IN_SECONDS; return date_i18n( get_option( 'date_format' ), $ts + $offset ); or better; $tz = new DateTimeZone( get_option( 'timezone_string' ) ); $offset_for_that_time = timezone_offset_get ( $tz , new DateTime("@{$ts}") ); return date_i18n ( get_option( 'date_format' ), ...



Top 50 recent answers are included