Tag Info

New answers tagged

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' ...


0

You need to add the prefix wpcf-. I mean that wpcf-source


1

I would create a custom post type of "tickets" - I find it easier to just use a CPT register plugin then remove it. You may prefer to code it yourself in which case plenty of information is available on the Codex. When that person clicks join use something like: //first define your post info $post = array( 'post_title' => 'Ticket for ...


1

Wanted: Add the ability to join/unjoint an event for registered client. Allow the admin to manage/review easily each event participants. Here is what I will do for a full management CMS Create a custom meta box that you will attach to your CPT "event". (this meta box will display the name of every person that are linked to the event, also, the ...


1

Firstly, it isn't an error, it's a warning: Warning: Invalid argument supplied for foreach() It's showing as an error because your PHP is configured that way. Research error logging levels for more details. As for why it's happening: $my_custom_field = $custom_fields['_source_link']; //key name foreach ( $my_custom_field as $key => $value ) ...


1

You could use the slug of each term as class name (and do the styling via CSS) <?php echo '<div class="col-lg-3 ' . $term->slug . '">'; // $term->slug is the class name echo '<a href="' . esc_url( $term_link ) . '">' . $term->name . '</a>'; echo '</div>'; ?> If you want to use dynamic terms and colors I recommend ...


0

I would just put the custom fields in the <li> after the <a> and then show/hide them with your preferred tooltip method, whether it be CSS, JS or a combination of the two: <?php if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <li> <a href="<?php ...


0

I was having the exact same problem on an archive page of a custom post type with a needless extra query; for pagination reasons. Searching for the same solution I found this post on Stack Overflow http://stackoverflow.com/questions/21303743/new-wp-query-or-pre-get-posts-to-view-all-posts-for-custom-post-type I had a play and added this line of code into ...


0

Use get_field instead of the_field. That way you can assign it to a varilable. $first_comment = get_field('first_content_block'); $second_comment = get_field('second_content_block'); echo do_shortcode("[vr_jsp] $first_comment, $second_comment [/vr_jsp]"); I haven't tried it, but see if that works.


1

Well, you use ACF for your custom field, right? In that case, replace the function "the_field" in your code with "get_field". the_field echoes the field already, so the field is echoed before your tab shortcodes return from the function do_shortcode and get echoed, which results in "having the content of the field before the tab" stuff. Happy Coding, ...


0

Custom field data saved in the wp_postmeta table. Best way to access custom field is using wordpress built-in functions. for example: <?php $mykey_values = get_post_custom_values('my_key'); foreach ( $mykey_values as $key => $value ) { echo "$key => $value ('my_key')<br />"; } ?> 0 => First value ('my_key') 1 => Second value ...


0

Now with the new information I would go with this: ?> <form method="post" action="where_ever_you_want_to_point_the_user_afterwards.php"> /* The loop: */ if (the_field('departures') == 'user_departure_location') { <input type="radio" name="destination" value="<?php echo the_field('destination'); ?>"> <a href="<?php ...


0

I am not sure if this is the best thing for you but I guess you could give it a try. Get the data from the input field and place it in the form on a hidden input or something and do the data attribute when the window of the Media Selection will close $inputValue = $('.some_class').val(); $('.fancybox').data('fancybox-group', $inputValue); I know this ...


0

I think what you are looking for is something like: <?php $post = get_post_meta($post->ID, '_cmb_fe_wysiwyg', true) ; if (!empty($post)) { ?> <div id="ingredientsNeeded"> <h3>Ingredients</h3> <?php echo wpautop( get_post_meta( get_the_ID(), $post . '_cmb_fe_wysiwyg', true ) );?> ...


0

Short answer: no. But if you want to use one loop for all your needed posts, you can do something like this: $args = array( 'post_type' => 'product', 'meta_query' => array( array( 'key' => 'cf_type', 'value' => 'fog', // need to have 10 with value 'fog' and 10 with value 'gof' ) ), ...


0

UPDATE: Okay, Looking at the Error, it should be easy. Just remove any Whitespaces or Clear Lines at the end of your Plugin file after the last "?>". http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc Did you copy&paste the code here? Because it seems like you have some whitespaces that should not be there in the ...


0

Should be easy enough. First, get the City. <?php $city = get_field('city'); ?> Then in your WP_Query, insert the taxonomy parameter: <?php $loop = new WP_Query( array( 'post_type' => 'member', 'posts_per_page' => -1, 'location' => $city ) ); ?> Et Vilola: you only get the Members that have the taxonomy $city.


1

I have taken a look at the source, unfortunately I haven't seen a nice way to pass the information without saving it. Which sucks - big time - because this really isn't anything that needs to be saved. A workaround would be to enable PHP Sessions by putting the following at the beginning of your functions.php: if (!session_id()) { ...


1

You can use the filter hooks 'add_post_metadata' and 'update_post_meta', when a function hooked there return anything but NULL the process of adding/updating metadata is stopped. The two hooks passes almost same args: NULL post id the meta key the meta value being added/updated Only last argument is different, in case of update is previous value, in ...


3

You should be able pull the field using get_post_meta. function give_linked_images_class($html, $id, $caption, $title, $align, $url, $size, $alt = '' ){ $classes = 'fancybox'; // separated by spaces, e.g. 'img image-link' // check if there are already classes assigned to the anchor if ( preg_match('/<a.*? class=".*?">/', $html) ) { $html = ...


2

Further to rafawhs answer, I think there is a little confusion as to what "custom post" indicates. Most WP developers (in my opinion) would assume you are referring to a "custom post type" which is a special type of data in WP. Pages are a pre-defined custom post type, for example. CPTs are mostly used to hold singular types of data, such as products, ...


1

Yeap, You can work with a page or single-cpt template with custom fields. In both case, you can use a plugin like ACF to set your fields. I think page template is a better choice in this case but if you are heading to custom-post-types, take a look at WordPress Template Hierarchy to understand how to create your custom single.php.


0

In qTranslate, there is this function that "dispatch" the language with the kind of string you have. Haven't tested it yet, but you could do something like: $myString = get_post_meta( $post_id, 'Functions', true); echo qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($myMeta); This will display the right language on your post based on the current ...


0

Good question Ciarán. I, too, was stuck trying to display custom fields in Genesis. This thread got me unstuck. And along the way I discovered that it is possible to take these ideas even farther. For example, I have found it helpful to use the Advanced Custom Fields plugin to create landing pages in WordPress. I can add as many WYSIWYG fields as I need in ...


0

If you have the ID, then a call to get_post_meta() passing only the ID will get you an array of all the values: $meta = get_post_meta( $post_id );


0

The action sends the $post_id just like you have so that's not the problem. Have you tried a var_dump of $_POST to make sure it's actually posting something other than null? Also, using the save_post action is going to be called every time a post is saved, so you probably need to use the save_post_{custom_post_type} action, replacing {custom_post_type} ...


0

$qry->is_main_query() will be true on every main query on your site, front end and admin. You need to add another more specific condition to target only the page you're trying to modify the query on, like is_post_type_archive('trucks').


2

Here is my solution for a Custom Post Type: Add this to functions.php. (Or, if you created a template for your custom post type like I did, such as single-instrument.php, add it to that instead of functions.php) // Display Advanced Custom Fields add_action('genesis_entry_header', 'type_of_instrument'); function type_of_attorney() { if ( ...



Top 50 recent answers are included