Quantcast
Browsing latest articles
Browse All 40 View Live

Comment by janh on WP_Query: apply an SQL function to meta fileld value

You'll have to use filters to change the SQL that WP_Query generates - are you OK with that or does that fall under manual SQL?

View Article


Comment by janh on Different favicon on different pages

Why not? Just set the appropriate meta tags and see what the browser make of it.

View Article


Comment by janh on Change number of posts to show on Archive page (custom...

is_main_query will probably be what you're looking for. It's only true for the main query that WP will execute to find the post(s) that the request is asking for, but not for consecutive queries (as a...

View Article

Comment by janh on I am trying to modify a plugin and am adding Jquery, but...

}); appears to be double, leading to an error.

View Article

Comment by janh on Update products with curl (bash)

Look at what your browser actually sends when you update a post. At the very least, you'll need a nonce. However, depending on what you're trying to do, it might be easier to use wp-cli or write a php...

View Article


Comment by janh on How to implement AJAX within a class storing shortcode...

I guess you have add_shortcode somewhere? The problem is likely that your AJAX request is a completely different request from the request to the post/page where your shortcode got interpreted in the...

View Article

Comment by janh on Wordpress varnish pages printed twice

You're not using edge side includes (ESI), right? Otherwise, varnish shouldn't change the body at all, so I'd look very closely at the backend. Do you see two requests from varnish in the backend's...

View Article

Comment by janh on Using abs() with custom field in orderby statement

Use posts_orderby.

View Article


Comment by janh on if statement with is_active_sidebar()

No, or rather: not necessarily. As long as either of those two sidebars are active (that is: contain widgets), the function will execute as if those lines weren't there at all. If both sidebars are...

View Article


Comment by janh on Can (slow) Internet speed get you a 500 server error?

Unlikely, but depends on the Browser, potential proxy servers etc. Look in your browser's developer tools at the request itself, especially at the headers & content of the response. Also look...

View Article

Comment by janh on shortcode is not rendered

Are you using the_content() in your template file? Do other shortcodes work?

View Article

Comment by janh on Forcing the Uninstall Hook to fail

You know, you could try it and find out AND share that knowledge with the community. -1.

View Article

Comment by janh on Update menu when saving settings

@Cyclonecode Sorry, I kinda completely trailed into my own thoughts that quickly diverged from what you had written. I've updated the answer and believe this should make more sense and not sound like...

View Article


Answer by janh for Ive got a term (get_term_by) but now I want to filter it...

Use WP_Query with Taxonomy Parameters. If you want posts that are in both categories, just add two conditions in tax_query (using an array for terms will get you posts that have at least one of those...

View Article

Answer by janh for Hiding the name of the user who is currently editing

The editing user is determined by wp_check_post_lock(), which in turn checks the _edit_lock postmeta field:function wp_check_post_lock( $post_id ) { if ( ! $post = get_post( $post_id ) ) { return...

View Article


Answer by janh for How can i hide post without thumbnails/featured images...

You can manipulate the main WP_Query just before it asks the database for posts. Looking for an existing _thumbnail_id meta field should suffice, so using the pre_get_posts filter, something like this...

View Article

Answer by janh for Echo custom admin field into a is_single()

$postids = get_option('codeable_posts_field');This will give you a string of comma separated post ids (according to your code, and if the user follows the instructions).array( $postids )will turn it...

View Article


Answer by janh for How should i sort “Last Update” Custom Column?

orderby will not contain the title of the column that is being clicked on, but its ID. Change your pre_get_posts filter to function my_organization_orderby( $query ) { if( ! is_admin() ) return;...

View Article

Answer by janh for Get Term names from WP Term Object

Sound like a strange thing to do, but I've seen stranger requirements, so I trust you have a good reason for that.$names = array();$slugs = array();$terms = get_terms(array('taxonomy' =>...

View Article

Answer by janh for Show all posts even if URL points to a single one

Testing with a standard install and twentysixteen, the problem lies within WP::parse_request. With your pre_get_posts action in place, simply removing that completely from the equation worked for...

View Article

Answer by janh for How to submit form data in the same page in WordPress...

Your jQuery event is bound to elements with the class submit, but your submit button in the form doesn't have that class.Either add that class to the submit button, or just target the form itself....

View Article


Answer by janh for Strange gibberish JavaScript in Editor – site hacked?

No, that's not what editors do, and yes, you should be worried.Revert to a clean backup, keep your core and plugins up to date.Change your WordPress and FTP/SFTP passwords. Make sure that there's not...

View Article


Answer by janh for WordPress broken after changing URL

Your config in WP is generally correct, but you have "forwarding" enabled at Namecheap, where they just redirect to your IP. Set it up as a real DNS A entry pointing to the IP.Then set up your IIS to...

View Article

Answer by janh for Can't write pdf file to upload directory using FPDF

$name apparently contains a URL. That won't work. Set it to a local path, as you did with $filename: $upload_dir = wp_upload_dir(); $filename = $upload_dir["basedir"] . '/deals/deal' . $page->id ....

View Article

Answer by janh for Video embeds work in backend, but are not parsed in frontend

I've just looked at the source of the WP_Embed class, and it appears they are not actually registering a shortcode, but hooking into the the_content filter.Change your code to$content_desktop =...

View Article


Answer by janh for How to Update multiple rows using $wpdb->update

It is a a bit of a stab in the dark, but I'm fairly confident that the problem is your foreach loop. It's broken (it will not execute anything because only an empty statement (;) is affected, and you...

View Article

Answer by janh for Why is my WP Query not returning first result's post meta?

$show_date = get_field('show_date'); $show_venue = get_field('show_venue'); // print '<pre>'; // print_r($show_date); // print '</pre>'; $query->the_post();You are setting the active...

View Article

Answer by janh for Why does my user not get added to the database on custom...

$_SERVER["PHP_SELF"] will NOT get you the current URL in WordPress, but will return /index.php (as that's the PHP script that is being executed). WordPress then doesn't know what to do with the data...

View Article

Answer by janh for Will WordPress Auto Update work on a site with Basic...

Yes, it will work. For Updates, WP reaches out to the update servers, there is no incoming request that is necessary. Your WP doesn't even have to be publicly reachable at all, you can have it behind a...

View Article



Answer by janh for Add indexing to meta_value in wp_postmeta

Don't limit the field, instead, limit the index, e.g.ALTER TABLE wp_postmeta ADD key(meta_value(100))This limits the index to the first hundred bytes of meta_value.You'll probably want an index on...

View Article

Answer by janh for curl POST work with user meta but not the custom user meta

You'll get the value as the first parameter, or you could get it out of $request, which is a WP_REST_Request object. Since you're using POST, the parameters out of $request->get_body_params() which...

View Article

Answer by janh for How to Handle Going Backwards in Navigation When Referrer...

You could use cookies. Set a cookie for each "level" (Messages, Series, Message) with the URL the user has last been on (including pagination). If no value is set for, say, Messages, because the user...

View Article

Answer by janh for How to hide specific categories from contributors

You'll have to change see_special_cats to something fitting. As you want to exclude contributors, but allow all others, you could use publish_posts (See the codex for all capabilities of...

View Article


Answer by janh for WP_Query: apply an SQL function to meta fileld value

You can use the filter posts_orderby. For a simple example:add_filter('posts_orderby', 'apply_sql_on_order', 10, 2 );function apply_sql_on_order($orderby, $query) {...

View Article

Answer by janh for does wordpress serve static files?

Usually: no.When WordPress is running on apache with mod_rewrite enabled, it'll use # BEGIN WordPress<IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /RewriteRule ^index\.php$ - [L]RewriteCond...

View Article

Answer by janh for How to Access custom database content with AJAX onClick...

I'd use the default WP AJAX API so WP can handle all the authentication for you. You'd add a function and an action to trigger it:function wpse_314311_get_quote() { // get quote from db // print json...

View Article


Answer by janh for Download external images if post is publish

Scheduled posts don't trigger publish_post, only updating the post itself will do that.Add an action for future_to_publish, see the reference on post status transitions. I don't believe that you'll...

View Article


Answer by janh for How do i add a unique body class to the wordpress...

If I'm not mistaken, you could just use body.wp-admin.index-php to target the dashboard.If you want to add something else, you can use the admin_body_class filter to manipulate the classes added to the...

View Article

Answer by janh for Most efficient way to get custom database records from 20...

I suppose the easiest way would be to have the action or other parameters in the button itself, i.e.<div class="mybutton" data-action="get_quote" data-type="literary">Get a literary...

View Article

Answer by janh for How to fix automatic redirects?

Those aren't really redirects, the "Hash" part of a URL (the # and anything after that) are purely client side and will not trigger another request to your server.The reason for it is AddThis. Here's...

View Article
Browsing latest articles
Browse All 40 View Live