Tag Info

New answers tagged

1

I think what you want is to create what WorpPress calls "Custom Post Types". Please have a look at the Post Type page in the Codex that explains what Post Types are and how to create custom ones. Basically, here is the code to create the Object custom post type : add_action( 'init', 'create_post_type' ); function create_post_type() { register_post_type( ...


1

You can use add_attachment action to set a default value for a custom field: function set_default_meta_value_62481( $attachment_id ) { add_post_meta( $attachment_id, '_show_attach', '1' ); } add_action( 'add_attachment', 'set_default_meta_value_62481' );


0

You have serious issues with your naming conventions, structure of your functions, invalid usage of reserved names and wrong values passed to parameters First, naming coventions. Function names should be lowercase letters, should not start with a letter and words should be divided by underscores (_). The same goes for custom post type and taxonomy names. ...


1

One common way to do similar task is creating a page template. For example: <?php /* Template Name: Reviews and Quotes */ get_header(); ?> <div id="content"> <div id="reviews"> <?php $reviews = get_the_reviews(); foreach( $reviews as $review ) { <?php <div ...


1

I think what you are looking for is get_post_meta() $courtesty = get_post_meta( get_the_ID(), 'courtesy', true ); // check if the custom field has a value if( ! empty( $courtesty ) ) { echo '<div class="courtesy">' . $courtesty . '</div>'; }


0

Got it. Plugin developer helped me looking at my suggested code. First, make sure you declare global $cfs (necessary when using Custom Field Suite Plugin). The following code checks for custom field named premium and if its value is set to 1 (which means it's supposed to be a premium post) and also for a custom field named expiration_date and if a value is ...


0

This sounds like custom development work, I doubt there is a pre-built solution. At its most basic, I'd say you need to a membership solution. There are a several out there, some free, some premium. Then in your front-end you can wrap the display of all the custom fields with current_user_can() using a capability that only that level has. For custom user ...


0

Here are few ideas: 1) You could try to compare with LIKE instead: 'key' => '_my_custom_field_key', 'value' => 'test1', 'compare' => 'LIKE' It should give you a SQL query with: ... LIKE '%test1%' ... 2) You might want to save the string as ,test1,test2,test3, to make the whole word search ...


0

I figured it out myself so I will post the answer here, please note that the original answer can also be found on StackOverflow. If the mods feel like this should be deleted from here and only remain, please go ahead. I thought it might be useful on both places. First the correct code, then an explaination: // Here we add a new user role, "cliente". ...


1

You can use FIELD or FIND_IN_SET: return "FIELD(mt1.meta_value, 'Head Teacher', 'Deputy', 'Teacher', 'Support', 'Clerical') ASC, mt2.meta_value ASC"; http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_field


1

There is, in fact! The global variable $wp_registered_sidebars stores the registered sidebars, and $wp_registered_widgets stores all registered widgets (by widget ID).


0

thanks for ur code Strik3r ..this helped me a lot..I finally got sorting by custom field to work...in functions.php function sort_meta_query( $query ) { if ( $query->is_archive || $query->is_category || $query->is_home ){ $query->query_vars["meta_key"] = 'fastest_speed_experienced'; $query->query_vars["orderby"] = 'meta_value_num'; } ...


0

I ended up going with a different approach which is a lot easier. I created a new custom user_meta called review_completed. This user_meta contains an Array of the post IDs of the submissions that they have reviewed. Then I simply added a new line to my review_args as seen below. $user_review_completed = get_user_meta($current_user_id, 'review_completed', ...


0

According to the codex for WP_Query, you should be able to tack on some meta related arguments to your args array (this is untested): $review_args = array( 'orderby' => 'post_date', 'order' => 'ASC', 'posts_per_page' => '1', 'cat' => 22, 'meta_query' => array( 'key'=>'reviewed_by', ...


0

you can do something like this //here is the code:- function modify_query($query){ //set this input in the orderby form //and check if its from the form and the request something like this if(!isset($_GET['check']) || $_GET['check'] != 'check') return; //then you can change the query as per request if ($query->is_main_query() && ...


0

I had the same issue, and found three ways to solve it. Types is really hard to convince to read data out of a different post than the current one in the loop... That's the first solution, just create a loop using query_posts() and get the data there via types_render_field() as usual. Just remember to reset the query afterwards if you're doing this before ...


0

You can do it with WP_Query:- $query = new WP_Query( array ( 'post_type' => 'product', 'orderby' => 'meta_value', 'meta_key' => 'price' ) ); Replace 'price' with your meta key. Reference:- http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters


0

One possible solution could be this - if ( empty( $social_icons_fields ) ){ $icons .= '<style type="text/css"> .socials-icons{display: none;} </style>'; //assuming that the div which has class 'socials-icons' is the div which supposed to be not shown return $icons; }


0

<?php // get an array of multiple values $post_meta_array = get_post_meta($post->ID, 'link'); // do not use 'true' as the third argument // echo the link for each value foreach ($post_meta_array as $post_meta) { echo '<a href="' . $post_meta . '" target="_blank">Images Source</a>'; }


0

“Call to member function format() on a non-object” means that $formatted_date is not an object. Why do you need 2 functions for this? Can't you just check the post meta for your custom field in the save routine? Especially with such a late priority the custom field should already be saved. function acf_set_expiry($post_id) { if ( ...


0

You could use the get_terms_orderby filter: add_filter( 'get_terms_orderby', 'wpse156153_get_terms_orderby', 10, 3 ); $categories=get_categories($cat_args); remove_filter( 'get_terms_orderby', 'wpse156153_get_terms_orderby', 10, 3 ); with function wpse156153_get_terms_orderby($orderby, $args, $taxonomies ) { return 'FIELD(t.term_id, ' . ...


0

I have been trying to figure this out forever! Perfect solution, Ashraf. Just to clarify for other newbies like me...Go to the Advanced Custom Fields dashboard & edit the field where it says 'Return Value'. Select the radio button for 'Image URL' instead of object or ID. It works perfectly in Genesis. Here is the code I'm using for my image field ...


-2

$today2 = date('Ymd'); $current_month = date('m'); $current_year = date('Y'); $today1 = $_GET['event_date']; //echo $xx = substr($today1,0,4); $current_month = substr($today1,-4,2); $current_year = substr($today1,0,4); //echo 'get-->'.$today1; //$today = ($today1 == '' || NULL )? $today2 : $today1; $args = array( ...


0

In my case I use a custom query so I can just use: $query = new WP_Query(array('post_type' => 'akteur', 'meta_query' => array( 'relation' => 'OR', array('key' => 'wpcf-kurzbeschreibung','compare' => 'LIKE','value' => $suchbegriff), array('key' ...



Top 50 recent answers are included