Hot answers tagged

8

UPDATE 21-01-2016 19:35 SA TIME - BUG FOUND!!!!! YEAH!!!!!! I finally found the bug. As you stated in your last update, the failure only happens when $post_content has a <!--nextpage--> tag in the content. I tested it, and did confirm that any other page after the page after the <!--nextpage--> returns a 404 and then the page gets redirects back ...


4

this the default template priority structure for categories: category-slug.php category-ID.php category.php archive.php index.php so if your category slug is "car", you can add file named category-car.php make sure you resave permalinks after adding the file, if it doest work :) more details here


3

There are several ways to deal with this problem. You could have a look for some syntax highlighter plugin, those will also bring you coloured text with highlighted keywords etc. pp. This is probably nice, if you use code quite often. I use SyntaxHighlighter Evolved. If you want to do this by hand, <code> is probably the HTML-element you want to use, ...


2

The theme uses the_excerpt() instead of the_content(). I had created a child theme before (so I don't modify the source theme directly: only the child one), so I only had to copy/paste the PHP file (archive.php) from source theme to child theme, and change the_excerpt() for the_content( __( 'Read more &#8250;', 'my-domain' ) );


2

First, you should always use the WordPress AJAX methods, not a custom function for that. See AJAX in Plugins in the Codex. With that practice in mind, you can set up your request like this. Change the AJAX URL to <?php echo admin_url('admin-ajax.php'); ?> and add the actionyou want WordPress to execute in the next step to your data . ...


2

Facebook's URL Debugger (https://developers.facebook.com/tools/debug/) finds the image just fine and I am able to share with the image. It could be that the image was somehow not there or not accessible when you first tried to share the URL. I would try to share it again and see if it works now. FYI, if you run into issues in the future, use the debug tool ...


2

I'll add this answer since it's not clear if you are asking about a category archive template or a single custom post template. To change single post templates, use the single_template filter and check if the post is in a specific category. There are a number of Conditional Tags you can use to determine what you're viewing and what terms an object has ...


2

Use the following for with Custom Text with Link. The above given code by @TheDeadMedic works only with text but no link. Code With Link and Custom Text like this: <?php previous_post_link( '%link','Previous Post' ) ?> <?php next_post_link( '%link','Next Post' ) ?> Hope this helps.


2

You can add following code to your functions.php in the Theme-folder. Change the Custom Post Type(movie) name and the title to your wishes. function wpse213979_new_title_text( $title, $post ){ if ( 'movie' == $post->post_type ) { // Movie is the cpt name $title = 'Enter movie name'; // The text you want to be shown } return $title; } ...


2

cracks knuckles Alright -- so first thing is first. Working w/ WordPress Databases Read this: https://codex.wordpress.org/Class_Reference/wpdb Avoid write SQL statements outside of the $wpdb object. Avoid writing SQL statements like wp_users instead do this: $users = $wpdb->get_results( "SELECT FROM $wpdb->users" ); This will help if you ever ...


2

SQL-wise, you only need to join to the wp_posts table once. Joining to the terms stuff will give you multiple rows, so it's probably easiest to group these and then use GROUP_CONCAT() to flatten the terms into a comma-separated string (updated to use LEFT joins): global $wpdb; $sql = $wpdb->prepare( 'SELECT p.ID, p.post_title AS Product, ...


1

Note that if you have the post slug, you don't need the additional taxonomy query to find that post, so it makes sense to drop the expensive taxonomy query in core in that case. Otherwise you could try instead the post_name__in parameter: [ 'post_name__in' => [ '<postslug>' ], 'tax_query' => [ [ 'taxonomy' ...


1

You most probably ran into problems with escaping code and HTML from each other. Try this (added line breaks just for better readability): <i class=" <?php echo (get_post_meta(get_the_ID(), 'Preis', true) != '') ? 'fa fa-check' : 'fa fa-times'; ?> ">


1

$url = wp_get_attachment_url(get_post_thumbnail_id(get_the_ID())); above code get current featured image url. I hope it work for you.


1

get_the_post_thumbnail ( $post/$post_id, $sizes, $attr ) will give you the featured image as html to output. get_post_thumbnail_id ( get_the_ID ( ) ) will give you the ID of the featured image so you can use it to get more information. Getting the thumbnail ID is essentially accessing the the post's meta data: $image_id = get_post_meta( $post->ID, ...


1

I've managed to get the following to work. Let me describe the technique so that you can decide whether or not to use it. the code uses two hooks, one fired just before the "side" meta boxes get placed, and another immediately after the "date/time" section in the publish meta box. the first hook (before) records the original post type, and then switches it ...


1

You want a filter on pre_get_posts restricted to the home page. Something like: function pregp_wpse_214875($qry) { if (is_home() && $qry->is_main_query()) { $qry->set('order','ASC'); } } add_action('pre_get_posts','pregp_wpse_214875'); You may need something other than is_home(), depending on how your "home page" is set up. The other ...



Only top voted, non community-wiki answers of a minimum length are eligible