Tag Info

New answers tagged

3

Solution from a cross post over at StackExchange from @birgire: The problem is that you run the clientarea_default_order callback too late. To fix that you only have to change the priority from the default one that's 10: add_action( 'pre_get_posts','clientarea_default_order'); to the priority of 9: add_action( ...


0

Have you check your result-set, what result you are getting in $query obj. another thing, there is no need to use 'relation' => 'OR', in meta query array, have a try with this as well. And instead of 'numberposts' use 'posts_per_page' this will help. :) or you can remove the meta_query and make your $arg something like $args = array( 's' => $keyword, ...


1

EDIT: If you use $post in a function, you have to define it of course: function xyz(){ global $post; //Your code } Initial answer, might help others: It appears to me, you do not use it inside an action or if so, you use it to early. It should work inside the 'init' action. So you could do something like <?php add_action( 'init', ...


1

Here is the fixed and modified code which was having the nonce action issue. <?php /* Plugin Name: Test Plugin Plugin URI: Test Description: Test Author: Test Version: 007 Author URI: */ // add all post types $clinical_post_types = array(); $post_types = get_post_types(); foreach ( $post_types as $post_type ) { $clinical_post_types[] = ...


2

You don't need to worry to much about your query as there is not much you can do about it. You can unfortunately not just only query categies, post titles and images natively using WP_Query. Post categories needs to be called separately inside the loop, just like featured images. If you dig deeper into core, you will see that all postdata and post terms are ...


0

Check the Parameters section in the WordPress Codex for get_categories. https://codex.wordpress.org/Function_Reference/get_categories#Parameters The type parameter only accepts 2 values (post & link) and you are trying to use accomodation. What you are probably wanting is get_terms. https://codex.wordpress.org/Function_Reference/get_terms So you ...


0

You are using third party code to generate those meta boxes, and I am not familiar with how that code works. In fact, based on your question I am not even sure exactly where the code fails. Your description of the problem is inadequate. I can point out that your code is overly complex. It can be simplified considerably: function get_destinations(){ // ...


0

I made this code with help from Google search. And it works fine. I added this code in single.php bottom of the post. Now, I simply add link in every post but image are same. Thanks. :) <?php if( get_post_meta($post->ID, "imglink", true) ): ?> <p><a href="<?php echo get_post_meta($post->ID, "imglink", true); ?>"><img ...


-1

Make attension if this code is not work then do first : Please add wp_reset_query(); after while loop you taken before this code, and try this $map = CFS()->get('hotel_address'); if($map){ // show map }


-2

Try use "image" custom field an select option "Image URL" (see my attached screen). Then use this code to obtain de URL: get_field("imagen_3"); Check remarked options:


1

As you have stated, rank is defined by a value in a custom field, so you would just need to get the value from the custom field and display it. You can try the following inside your loop global $post; // Just make sure the custom field name is correct $rank = get_post_meta( $post->ID, 'custom_field', true ); // Display the title and rank echo 'Rank ' ...


0

For me Hameedullah Khan answer worked well. I've made just a little fix because my new fields have broken the page layout. So in the jquery code I've added jQuery(document).ready(function($) { field = $('#custom_user_field_row').remove(); field.insertBefore('#password'); ...


0

Using jQuery you can add a class to an anchor tag like this. <script type="text/javascript" > $(document).ready(function () { $('.custom-field-class').children('a').addClass('some-class'); }) </script>


1

Per comments just trim the $colors before use: if ( get_post_meta( get_the_ID(), 'hex_colors', true ) ){ $colors = get_post_meta( get_the_ID(), 'hex_colors', true ); $colors = explode( ' ' , trim( $colors ) ); foreach( $colors as $color ) { echo '<div>', $color, '</div>'; } }


0

you have to use the serialize function in case you are using integers: $args = array( 'meta_query' => array( array( 'key' => 'my_meta_key', 'value' => serialize(strval($my_vale)), 'compare' => 'LIKE' ) ) ); $posts = get_posts( $args ); and you are ready, print_r($posts); and see ...


0

Just to check the basics first: have you already gone into 'Screen options' at top right? After you click that tab, is your custom post type listed there with a checkbox? If not then you know it's something in the code (if it's there unchecked, tick the box and it should appear in edit page).


1

If you're getting empty divs like that, you probably have two spaces between each value. In that case, only the first space would be treated as a delimiter. I think the best thing to do would be to separate them with some other physical character and then remove all spaces from the individual values (this is what the call to trim() below will do). I would ...


0

Enjoy it easy and the best way <div class="col-md-8"> <?php $aboutcompanys = get_post_meta(get_the_ID(), 'aboutcompany', true)?> <div class="teaser"> <?php foreach($aboutcompanys as $aboutcompany){ ?> <img src="<?php echo ...


0

I figured it out myself thanks to this Q&A. The problem was with closures in loops. Can't really explain what happens but it works for me. jQuery(document).ready(function($){ $.ajax({ url: ajaxurl, data: { 'action':'ajax_action', 'post_id' : 18 }, success:function(data) { var hero ...


0

It should be stored in the wp_usermeta table under the entreprise and os user meta keys. You should consider using prefix on your custom meta keys, to avoid name collison. Example: kerzzy_entreprise kerzzy_os It should show up with: SELECT * FROM `wp_usermeta` WHERE `meta_key` = 'entreprise' in your MySQL administration tool, e.g. PHPMyAdmin. ... ...


3

To pass data from js back to PHP simplest way is use json_encode or, in WP, its wrappers wp_send_json, wp_send_json_error and wp_send_json_success. Usage example: On PHP side function get_latest_product_meta() { $post_id = (int) filter_input(INPUT_GET, 'post_id', FILTER_SANITIZE_NUMBER_INT); $post_id or wp_send_json_error(); // array_shift ...


0

use here set type method: add_action('init','engineCreateRecurringSchedule'); add_action('engineRecurringCronJob','engineDaysToGoUpdate'); function engineDaysToGoUpdate(){ // Arguments to get published posts with 'engine' post type. $engineDaysToGoArgs = get_posts( array ( 'post_status' => 'publish' 'posts_per_page' => -1, ...


0

You can use the get_post_types function to fetch and search through the registered post types up to that point (the init hook where you would normally register the custom post type). You can possibly use a later hook like wp_loaded to do this check before trying to register the post type in case some other (not related to any of yours) plugin might have ...


0

In cases like this its better off (IHMO) to simple use a custom query using the $wpdb class ex: <?php global $wpdb; //first get a list of all meta keys $keys = $wpdb->get_col("SELECT distinct meta_key FROM $wpdb->usermeta"); //then prepare the meta keys query as fields which we'll join to the user table fields $meta_columns = ''; foreach ($keys ...


0

Your basic query logic looks fine assuming you want an AND relationship between the first, middle, and last names but query_posts is never, ever, ever the right way to do anything. Note: This function isn't meant to be used by plugins or themes. As explained later, there are better, more performant options to alter the main query. query_posts() is ...



Top 50 recent answers are included