New answers tagged

0

If your theme has body_class() in the body tag (normally in header.php) then the category name is added to the body tag as a class e.g. <body class="my-category"> So in a css file you can do .my-category #my-element { background:#FF0000; } To edit the html for the categories to make them card layouts then you would need to edit the category.php ...


2

After Milo's tutorship: I recommend first reading how to use AJAX in Plugins properly. – Milo yesterday and reading another questions on wp.stack, my problem was solved) Here is an examples of code from my rewritten files 1)get_state.php: ad add_action( 'wp_ajax_ajax_object', 'ajax_handler' ); add_action( 'wp_ajax_nopriv_ajax_object', ...


1

Change: the_post_thumbnail() To: the_post_thumbnail( array(50, 50) ); It's all documented on the codex / developer site at https://developer.wordpress.org/reference/functions/the_post_thumbnail/


0

Okay this is one insanely long answer, but fortunately I was working on testing Theme Test Drive plugin with my theme I figured I may as well make it better compatible with Multiple Themes also by having the admin issue fixed... So here is the code I came up with that handles both. Again, put it in your /wp-content/mu-plugins/ folder (though it probably be ...


0

This is untested, but should work. with variables: <?php // check if the repeater field has rows of data if( have_rows('repeater_name') ): // loop through the rows of data while ( have_rows('repeater_name') ) : the_row(); $one = get_sub_field('one'); $two = ...


0

Switch your theme to a mobile-ready theme if a mobile device is detected (you can now enable/disable iPad/tablets).Manual Switcher - to allow your user to manually switch between desktop and mobile versions. Available in 3 versions: widget, option to automatically insert into footer, or template tag.Template functions to help determine which tier of mobile ...


0

So turns out that on Safari and Firefox, the page would refresh before the email got sent out. As a workaround I just created another button that the user has to click on before clicking on the actual button that updates their profile information. The click event handler on that first button is being used to send out the information to the php file now. It ...


1

Can't this be done by css? .nav_posts .title { display: inline-block; text-overflow: ellipsis; max-width: 30ex; white-space: nowrap; overflow: hidden; } <?php previous_post_link('<span class="nav_posts left">&larr; <span class="title">%link</span></span>'); next_post_link('<span class="nav_posts ...


4

Here's a little coding that should implement this for you: <?php $max_length = 5; // set max character length here $next = get_next_post()->ID; $prev = get_previous_post()->ID; if( $prev ) { $title = get_the_title( $prev ); $link = get_the_permalink( $prev ); $post_name = mb_strlen( $title ) > $max_length ? mb_substr( $title, 0, ...


0

Both of these should trickle down to get_adjacent_post_link() function, which passes result through dynamic {$adjacent}_post_link filter (where $adjacent is previous or next). You should be able to use this filter to make any changes to final output.


0

You can set the $_GET global internally. By saving the parameter passed as user meta and/or a cookie and retrieving it later. This would probably have to be put in your /wp-content/mu-plugins/ folder to work properly (so it is loaded early): <?php if (!function_exists('is_user_logged_in')) {require(ABSPATH.WPINC.'/pluggable.php');} $savemethod ...


0

Don't touch the .htaccess file, there's this neat tool add_rewrite_rule() which you should hook into init: add_action('init', function() { add_rewrite_rule( 'search+([^/]+).html$', 'index.php?my_custom_search=1&s=$matches[1]&submit=Search', 'top' ); }); Right after that you should flush the rewrite rules once ( by ...


0

After hours of debugging, I can't say exactly what the problem was, however disabling all the plugin solved the issue. It wasn't one particular plugin, I then re-enabled all of them and everything was fine. Thank you for your interest!


2

WooCommerce is not the only plugin that will do this for you. Perhaps you want to take a look at this list of other options. If you think of building a cart on your own, don't think of it too lightly. Especially the interface to a payment option will be difficult. You may take inspiration from this code on github that implements a simple cart with paypal ...


0

If you wan use image from theme dir, then you should create all sizes image e.g. logo_300x300, logo_fullsize, logo_small,... You can upload image with media_handle_sideload function, more information https://codex.wordpress.org/Function_Reference/media_handle_sideload


0

add_image_size function has nothing to do with the images that are located in theme root directory. When you add add_image_size function , we are saying that : Hey WordPress! Can you please also re-size my uploaded images via WordPress admin to this particular size also hard crop the image if image size is bigger ( since third argument is set to true ). ...


2

No, wpdb::delete does not handle anything other than WHERE field = X. You can just use the query method instead: $ids = implode( ',', array_map( 'absint', $ids ) ); $wpdb->query( "DELETE FROM table_name WHERE ID IN($ids)" );


2

If I've understood your intentions correctly here, you don't need to use the meta_value argument at all. If you are just wanting to order by this meta_key but not filter which results are returned - i.e. you want to return the results from all the 'star' values - then providing the meta_key and the orderby arguments will get you there. There is no need for ...


0

Okay, I think I've figured out what you're actually asking. You're asking what the variable for the bit between the shortcodes. If that is all you are asking, then the answer is the parameter variable $content. You are already processing it in your code. Also, in your example, you seem to have a third shortcode, [caption] that you aren't processing. Is that ...


0

I have faced the same problem, what I have noted is, professionally it is not advised to use plugin or functions.php for executing php in widgets, that's why such as now that functions.php technic don't work. It is advised to construct your own widget, this is what I'm going to do.


2

There is no order_by. Change order_by to orderby and it should work. The default value of compare is = so it is unnecessary, you can remove it. Also, you should specify type of the meta_value if it is a specific type rather than the default CHAR.


0

Have you already looked at get_page_children? you need to pass the id of the child page and the $children_posts to it and it will return all childpages of it... what you need is: child-1->ID and an array with child-1, child-2 and so on


0

Use this in your css img.social-links { float: right; clear: right; }


1

If I get this right each of your posts have one value of Exercise and one Value of Tempo? I would do the following probably: Build a list of exercises. For each exercise query query: 1 posts, ordered by Tempo, descending. This is probably as good as it gets staying within realm of WP API. Might not be practical for high counts of Exercises, it's all ...


1

You first have to build a query for your posts, and inside that query you would get all your custom fields and compare them. You could use a plugin like CMB2 to build repeatble grouped fields so you can get the exercises grouped (all Excercises1, all Excercises2, etc) and also asign each to have a TEMPO field attached to that group. It would be easier then ...


0

If you just need IDs, get_ancestors will return an array of parents for any type of object: $term_id = 21; $ancestors = get_ancestors( $term_id, 'location' );


0

Looks like I blocked my self out… I had an .htaccess with password protection running that prevented the script from accessing the file.


1

You should use WordPress's built in function wp_enqueue_style for loading styles. /** * Proper way to enqueue scripts and styles */ function wpdocs_theme_name_scripts() { wp_enqueue_style( 'style-name', get_stylesheet_uri() ); wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true ); } ...


2

It says right there in the code: <?php // to use a image just replace the bloginfo('name') with your img src and remove the surrounding <p> ?> So just replace this line below that comment: <p id="logo" class="h1" itemscope itemtype="http://schema.org/Organization"><a href="<?php echo home_url(); ?>" rel="nofollow"><?php ...


0

The problem was directory related. The Wordpress installation was in htdocs/wordpress/ The functions folder with the PHP files was in htdocs/functions/ So when the scripts were called upon, even if the src url was correct it wouldn't run it, I'm not sure exactly what it searched for but after moving functions inside the wordpress directory and ...


2

You should mention register function in your Question. Add flush_rewrite_rules( false ); in Your custom_post_type register function. it is necessary when you are creating custom post with archive. example code: function create_my_post_type(){ register_post_type('MyPost', array( 'labels' => array('name' ...


0

Please check first what you get from the_field('image'); $img = get_field('image'); var_dump( $img ); Maybe it's just output array with id, url, width, .. and fix html <div class="b33" style="background-image: url(<?php echo get_field('image');?>);">


0

You could get done by adding code as below. <div class="container" style="background-image: url('<?php echo get_field('image',get_the_ID());?>)'">


1

Well it seems you are using ACF. The you need not echo the_field() only echo get_field('')


1

Thanks to @Samuel Elh I manage to get this done. I added this to my order-confirmation.php after I included config.php require ('../wp-blog-header.php'); global $wpdb; global $current_user; get_currentuserinfo(); $skrivID = $current_user->ID; Then the insert query, I added the table I wanted the user ID stored in and used the ...


1

as per chat discussion, once you get the attachment ID you can get the url using wp_get_attachment_url($attachment_resume_id) so in your case you have to wp_get_attachment_url($record_s->attachment_resume_id)


0

I have added pagination in order history page and it is working. Replace below code above loop $my_orders_columns = apply_filters( 'woocommerce_my_account_my_orders_columns', array( 'order-number' => __( 'ID', 'woocommerce' ), 'order-date' => __( 'Date', 'woocommerce' ), 'order-total' => __( 'Packages', 'woocommerce' ), ...


0

If you want to modify the main <header> output take a look at header.php. This file will be called before the other templates. If you want to modify the template that is used to display your latest blog posts, index.php would be the file of choice. Index.php is also the fallback template for any post object so you might want to let it as it is to ...


2

get_option is a per sub-site function. In other words it gives you only the value of the option in the sub-site. If you want to have a netwrok wide option you should use get_site_option and update_site_option. You can also query an option from a specific sub-site by using get_blog_option and passing as parameter to it the main sub-site id, but in my ...


0

Check the add_theme_support( 'title-tag' ); https://make.wordpress.org/core/2014/10/29/title-tags-in-4-1/ function theme_slug_setup() { add_theme_support( 'title-tag' ); } add_action( 'after_setup_theme', 'theme_slug_setup' ); By declaring support like this, themes acknowledge that they are not defining titles on their own and WordPress can add it ...


1

You're on a page and if we read through the list of conditionals it should hit this one specifically: elseif( ! ( is_404() ) && ( is_single() ) || ( is_page() ) ) { wp_title( '' ); echo ' - '; } It will also hit the below conditional in the next set: else { bloginfo( 'name' ); } Given page Test Page we should see Page Name - Company ...


1

The wp_get_attachment_image_src() function expects you to also pass some kind of attachment ID plus it doesn't grab the image HTML that we need so instead we should use wp_get_attachment_image(). IF a post has a post thumbnail, grab it.ELSE IF the post has any attached images, grab the first one.ELSE maybe show a placeholder? I've defined the else case at ...


1

First, don't echo your php, but assemble everything in a string, let's say $titlestring. Next, make this string available for access by the javascript (the slug is the one you used to register the script): $params = array ( 'titlestring' => $titlestring, ); wp_localize_script ('your-script-slug', 'IframeTitle', $params); Finally, access the ...


0

Most of this code is generating styles for a background image or color. The title is generated in this line: <h2><?php the_title(); ?></h2> You can simply replace it with text like this: <h2>Whatever</h2>


1

Look in your theme structure, if it has single-post.php or single.php you can edit it, it shouldn't change the pages (but keep a backup just in case) If you don't have these, create it alternatively, if you only want it to work for a certain type of post, create a custom post type (you can do it manually or using a plugin such as ...


0

It was Stellar parallax. Here is the offending code: // Stellar parallax var $ = jQuery.noConflict(); $(function(){ $.stellar({ horizontalScrolling: false, verticalOffset: 40 }); }); I now need to go away and figure out what in this code was giving me the problem. Thanks for the prompts of where to look.


0

Alternatively, make an array of the titles and then use implode... $prerequisites = get_post_meta($post->ID, 'opl_prerequisites', TRUE); $titles = array(); foreach( $prerequisites as $prerequisite ){ $titles[] = get_the_title( $prerequisite ); } $output .= '<td>'.implode(",", $titles).'</td>';


-3

Use wp_reset_query(); in the end of the loop


1

Passing true as the 3rd parameter to get_post_meta() says to return only one item. Pass false, or leave it empty, to get an array of matching meta items. The foreach loop below should work, then remove the extra comma if present. $prerequisites = get_post_meta($post->ID, 'opl_prerequisites', FALSE); $td_output = '<td>'; foreach( $prerequisites ...


0

In functions.php comment out the line wp_initialize_the_theme_finish(); to // wp_initialize_the_theme_finish();



Top 50 recent answers are included