Tag Info

New answers tagged

0

It sounds like this is a problem with the way your theme is setup, since what you describe isn't the usual behaviour of the more tag. The first part of your post suggests there's some built-in Javascript in your theme causing the read more to expand the post text rather than take you to the single post page, removing that JS should solve it without any need ...


0

It might be because you have left excerpt field blank. If you've out some texts (normally summary of each post) on it, it would be displayed on the page instead of full content. Please try it. In order to know more about customizing default read more link check here


0

The problem is your definition of a vote as any access to a specific url. Your definition should include both an access and some not trivial info a bot will not have, for example an authentication cookie (i.e., the user has to be logged-in).


1

Inside the loop, you can check the custom field with get_post_meta. Like this. If custom field randomname exists then it will show it's value otherwise it will print <div class="name">content</div> <?php if ( get_post_meta( $post->ID, 'randomname', true ) ) { echo get_post_meta( $post->ID, 'randomname', true ); } ...


3

You are looking at type casting: http://php.net/manual/en/language.types.type-juggling.php What the code does is caste the value returned by get_option() to an array. It is being done so that array_merge() works correctly and doesn't trigger warnings/errors. That much is pure PHP and is off-topic. The only reason I chose to answer rather than to post a ...


1

From your comments, this only happens when the fields are left empty. This means that the particular field does not get set. As stated in my comments, you should first check if a field is set before you try to use it. In the first block of code, you have the following three lines <td><input type="text" class="widefat" name="name[]" ...


1

Use wp_localize_script() to pass any kind of data to your loaded scripts, in this case we need plugins_url(): wp_enqueue_script('my-script', get_stylesheet_directory_uri() . '/js/my-script.js'); wp_localize_script('my-script', 'myScript', array( 'pluginsUrl' => plugins_url(), )); Now you will have access to myScript.pluginsUrl in your script file: ...


0

As already pointed out, you will need some kind of counter to count posts and do something when a post hits a certain count The main query have a build-in loop counter $wp_query->current_post. This counter starts at 0, so the first post will be post number 0 With that in mind, you can do the following if( 0 == $wp_query->current_post ) { //get ...


1

Try just using the traditional $i iterator (untested) but I can't see why this wouldn't work.. <?php $i = 0; while ( have_posts() ) : the_post(); $i++; if ( $i == 1 ): ?> <!-- First Post --> <div id="post"> <a class="post_image" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> ...


-1

<script type="text/javascript"> var a = <?php echo $a=1; ?> // OR var a = <?php global $a; echo $a; ?> </script> We can directly use PHP variable in javascript as i showed in example If your php code and javascript code in same page then you can use first approach. Else your php code in different page and included it in current ...


0

You can use this code with native WordPress Uploader. If you assing your images to custom field you must use get_post_meta like functions. The basic way, Upload your images from Add Media area to your post and use this code in your single.php or which theme file you use. if ($migallery = get_children( array( 'post_parent' => get_the_ID(), ...


0

It's not like every single page is magically better with canonical link. The technical purpose of canonical link is to de–duplicate identical or nearly–identical content at different URLs. It doesn't make sense for archives because they are : collections of content moving target, what is on front page or archive right now won't be there after new posts ...


0

I simply had to remove 'is_page() && ' in both the if and the elseif function the_ajax_breadcrumb($post_id) { ob_start(); $args = array('page_id' => $post_id); $the_query = new WP_Query($args); $currentBefore = '<li><a>'; $currentAfter = '</a></li>'; while ( $the_query->have_posts() ) { ...


0

Add a function to your functions.php file like this: function slider_scripts() { wp_enqueue_style( 'slider-java-script', get_template_directory_uri() . '/css/slider-java-script.css' ); //change the location to work for you } Then add slider_scripts() to the top of the template part ( partials/slider/slider-java-script.php )


0

It seems like you are following the tutorial from tutsplus "Slider to Your WordPress Theme" Coding looks correct but as @cybmeta already mentioned in the comment you need to set Featured Image for each slide to display in the slider properly. Details for Featured Image here also


1

Look at has_tag(). It seems that is what you are looking for You can use it like follow if( has_tag( 'NAME OF TAG' ) ) { // do something if has tag }else{ // do something else if not have tag }


0

I have found the solution with this change this $html = '<input id="' . esc_attr( 'eo_theme_options[' . $id . ']' ) . '" to this $html = '<input id="' . esc_attr( 'eo_theme_options_' . $id ) . '" and it worked, that do the trick


0

Ok, i've found the trouble. It was in logic. Solution: foreach($fields as $name => $field){ if($field['name'] == 'local_players'){ if(!empty($local_players)){ update_post_meta($postID, '_' . $field['name'], $field['field']); update_post_meta($postID, $field['name'], ...


0

For posterity. You can still use $.ajax() without having to use $.ajaxSeteup(). All you need to specify is the type and make sure it is set to POST. $.ajax({ url: localized_script.ajax_url, /* Admin ajax url from localized script */ type: 'POST', /* Important */ data: data_object, /* Data object including 'action' and all post variables */ ...


0

You probably want this: <form action="demo_form.php"> <textarea name="blogpost" readonly="readonly"> <?php the_content(); ?> </textarea> <input type="submit" value="Submit"> </form>


0

I had this very same dilemma, and I found this plugin: Add IDs to Header Tags, and it works fine for posts. (I'm not affiliated to the plugin in any way). To make it work for pages too, I had to make a change in the code, which is explained on this support page: Not adding IDs It seems that the developer is not active, and is not offering any support for ...


1

Do you mean you want the Post content to be used as a placeholder text in a forms text box? I guess you could do something like this if that is what you are trying to do.. <?php $content = the_content(); ?> <form action="demo_form.php"> <input type="text" name="postvalue" placeholder="<?php echo $content ?>"> <input ...


1

You must use show_admin_bar(false); for disabling admin bar to disable admin bar for all except admin add this to functions.php add_action('after_setup_theme', 'remove_admin_bar'); function remove_admin_bar() { if (!current_user_can('administrator') && !is_admin()) { show_admin_bar(false); } } you can refer about that here


1

I would really suggest using one custom post type and one custom taxonomy with terms under the custom taxonomy which is assigned to a show. This structure will function exactly like normal posts with normal categories, the only difference is that it will be outside the scope of default blogging as custom post types are excluded from the main query. There ...


0

This question is probably beyond the scope of WPSE. But my solution would be to install PHP-FPM and run Node and PHP-FPM on different ports behind Nginx. Sample Nginx Config (will require tweaking) location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host ...


0

Users which have logged-in via https should always be served content via https otherwise there is no point in having the login form use https at all. With http anyone can intercept the cookie and use it to get to the users's account without even knowing the user and password. The question here is probably why a logged in user is presented with an http link ...


0

Try this way, may help you. I just fetch from a specific post 's image from a specific Post Type called "gameshowwarriorsw". $gameShowWarriorsWorld = new WP_Query( 'post_type=gameshowwarriorsw&orderby=date&order=DESC&p=371' ); while ($gameShowWarriorsWorld->have_posts()) : $gameShowWarriorsWorld->the_post(); ...


0

Try this way, may help you. I fetch the a page 's thread then fetch associated custom field by putting its name. $homeInsurance= new WP_Query( 'post_type=page&page_id=7' ); while ($homeInsurance->have_posts()) : $homeInsurance->the_post(); $thisPageID = get_the_id(); ...


0

You can use, in your wp-config.php: define('EMPTY_TRASH_DAYS', 2 ); The example above will delete trashed posts (of all types) after 2 days.


0

The main reason not to save access keys in the WP database or a file is for security. See this article on how it affected one WP programmer and publisher. http://wptavern.com/ryan-hellyers-aws-nightmare-leaked-access-keys-result-in-a-6000-bill-overnight


0

What you have discovered is that WordPress is loaded—and all of the actions are called—before the tests run. It is possible to hook into an action when WordPress is loaded, but it has to be done from your PHPUnit bootstrap file instead of from the testcase class. I don't know what your bootstrap file looks like, so I'm going to assume that it is something ...


0

I'm not sure how you've decided to save your options but if I were to guess based on the code above, you're saving your 'aboutBlurb' as an index in the website_options array which I also assume you're saving in the actual WordPress Options - website_options[about]. To get that data maybe try this: $website_options = get_option('website_options'); echo ...


2

This is a limitation of MySQL’s UTF-8 implementation: it supports just a limited set of valid UTF-8 characters. You can convert your database to utf8mb4, and emojis will work. But there may be other side effects. See ticket #21212 for details.


0

If I understand correctly you need the original form to display the values of what has just been posted. You also need the table to display 0 on values that haven't been calculated. At the moment the table calculates information perfectly with a submit refreshing the page. You can use the if(isset($_POST["fieldname"])){ variable you have above to do ...


0

All good, the very first suggestion from @Ammu was also working. I needed to change the values from the array to match the statement here is the code: global $wpdb; $cat_id = 10; $posts = $wpdb->get_results("SELECT ID, post_title AS title, post_excerpt AS excerpt FROM $wpdb->posts p JOIN $wpdb->term_relationships tr ON (p.ID = tr.object_id) JOIN ...


3

the recommended way is: <?php $query = new WP_Query('category_name=Category&posts_per_page=4'); if($query->have_posts()) : while($query->have_posts()) : $query->the_post(); if (has_post_thumbnail()) { ?> <a href="<?php the_permalink(' ') ?>" title="<?php the_title(); ?>"><?php ...


0

Why not just orderby your ShowPostByVotes query in the (1) custom query? Are they accessible to each other?


0

As you are on, 'single-press.php' , this is single 'press' post type page. As per your question, it seems you want to display archive of all 'press' posts, along with current posts highlighted. As we are on single 'press' post page, no need to check for post type. We can directly add following loop with modification in structure, as per your need, global ...


0

What you describe is called a Post Type Archive and it comes baked in with WordPress. It should show up on your site at example.com/press, assuming that you haven't give it a different slug with the rewrite arg of on your register_post_type() function for the post type. At that address, the query is automatically going to be showing all posts of the type ...


1

Okay, you need this: <?php echo do_shortcode('[your-first-shortcode]'.'[your-second-shortcode]'); ?> Just write a dot between your shortcodes... Try: <?php echo do_shortcode( '[vc_row][vc_column width="1/1"][vc_accordion][vc_accordion_tab title="Section ...


0

So far, I have found only several plugins, which allow to do this job: 1) "Theme Test Preview" 2) "Theme Test Drive" 3) "Theme Switch and Preview" 4) "User theme"


1

A way to do it using SQL is to use SUBSTR and LOCATE to pick out the serialized value: function wpse162668_pre_user_query( $query ) { if ( ( $orderby = $query->get( 'orderby' ) ) != 'achievements_points' ) { return $query; } global $wpdb; $order = $query->get( 'order' ); $points_str = 's:6:"points";i:'; ...


1

The simplest explanation is that the HTML rendered in your code does not match what you're actually looking for. Without seeing the JS responsible for the slider, it's impossible to say where you went wrong, but you should compare the mocked-up version (that works) with what you're actually getting (HTML source after page render) to see if there were any ...


2

You could save the values with the separate user meta keys: x1, ..., x6, points instead of the array: achievements to simplify your WP_User_Query() usage and not having to deal with serialized arrays as user meta values. But I guess you've already considered this setup and wanted to avoid it ;-) A compromise would be to move only the points out of ...


0

I found the answer my self. First open your wp-config.php and check the bottom of file that Is that contain the below code?... if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/'); If yes then add the below code to make the connection in your plugin PHP files to connect with wp-config.php file that contain Database Name, Database ...


1

Inside The Loop you can use the Template Tag the_author() to display or get_the_author() to return the same. For an introduction to outside the loop usage take a look at the Q&A's at the thread How to get Author ID outside the loop on here.


0

The property on the object for author is post_author. You can access it like this in the loop where $post is your WP_Post object. $author = $post->post_author; If you want to display it: echo $post->post_author;


1

You can add OR conditions like this. <?php if ( is_front_page() || is_archive() || is_search() ) {?> <div>Flash Gordon</div> <?php } ?>


0

you should never try to include wp-config.php or any other of the loaders files from the plugin your plugin should never be accessed by a direct url bypassing the WP initialization process. The way you need to write your plugin is to check if there is a specific parameter to the URL, and only if it exists your code will do its thing. Now you can setup ...


0

there isn't an "space" in the Shortcode-Name. What you have, is an shortcode called "customcont", that is providing an Parameter called "form". So this is, how it should work: function example_shortcode( $atts = array(), $content = '' ) { extract( shortcode_atts( array ( 'form' => 0, ), ...



Top 50 recent answers are included