Tag Info

New answers tagged

0

The end of the_content() is a </p> tag. It sounds like you want to include your end mark before that last </p> tag. If so, you need a function that filters the_content(). Something like: function yang_end_mark( $content ) { $content = substr_replace($content, '<span>&#128282;</span></p>', strrpos($content, ...


0

No. There is no user supplied data in that string. You only have to escape user supplied data. The only why this could be hacked would be if someone managed to push something nasty through the __() function but that would mean a server level hack, if possible at all, and if that were the case no escaping is going to fix anything. With that kind of hack, the ...


0

There are two methods: The one mentioned in this question. And the one mentioned in this Codex page.


1

Your have two major issues here The string you are building is correct, but it gets overriden on each iteration of the loop, which at the end will only hold the info from the last post. You need to define your variable outside the loop and then concatenate your info to that variable across the entire loop in order for you to display all postdata from all ...


0

If you change the paramter "number" to 2 in the line : $terms = get_terms( 'issue', 'orderby=id&order=DESC&number=1' ); You'll get the last 2 terms, so the 2 you want ?


1

The answer typically depends on where your translations come from. WordPress core doesn't usually escape strings such as this, but you may wish to do so in your plugin. A translation might come from an "untrusted" source and could, in theory, contain malicious JavaScript, and escaping would protect you from this. In reality that's unlikely, but escaping ...


0

No. The contents of your echo statement will be output to the browser with no problems.


0

The "PressRoom by Newswire" (a free plugin that I authored) creates a press room page on the user's website. It will also helps the user publish and distribute press releases. PressRoom by Newswire allows the user to create "pin style" content blocks for the new press room page. Control over the style of these blocks is provided through an interface that ...


1

I figured out the issue, my site had the following in wp-config.php. Also WP-config.php had to be placed at the site root define('FS_CHMOD_DIR', true ); define('FS_CHMOD_FILE', true ); define('FS_METHOD', 'direct'); Removing the above resolved the issue.


0

<?php function theme_footerscript(){ wp_enqueue_script('main_js', get_template_directory_uri() . '/assets/js/main.js', array('jquery'), '1.0', true); } add_action('wp_enqueue_scripts', 'theme_footerscript'); ?> this way you will add a script on footer (add this code in functions.php). if you set the last parameter to true, then the script will ...


0

use % to set the template(style) or you can use :nth-child(16n+1) ... <?php if (have_posts()) : ?> <?php $count = 0; ?> <?php $st = 16; //after how many blocks you want to repeat the pattern <?php while (have_posts()) : the_post(); ?> <?php $count++; ?> <?php if ($count%$st == 1) : ?> <div class="style-1"><?php ...


1

try this $post_id = 11; $post = get_post($post_id); $slug = $post->post_name; <a href="<?php get_site_url(); ?>/abstract/<?php echo $slug; ?>" title="<?php the_title_attribute(); ?>">Abstract</a>


0

get_query_var() only works with the Core WP_Query object: Retrieve public query variable in the WP_Query class of the global $wp_query object. https://codex.wordpress.org/Function_Reference/get_query_var Your mistake is a simple PHP one: The key is foo, not bar. $foo = $_GET['foo']; echo $foo; But please do not echo user supplied data to the ...


0

I couldn't find any other way to resolve this problem. i tried a lot of thing to add link to the category menu but without any success.


0

This one is similar to the one posted above, however there is an extra loop to display all paragraphs after the content. <?php $content = wpautop( get_the_content() ); $content = explode("</p>", $content); echo wpautop( $content[0] ).'</p>'; ?> <p>Special content or page breakpoint</p> <?php ...


0

an echo before inserting content, are you sure ? Possibly sending headers, blocks insert POST request and set pid to empty value. if (isset ($_POST['description'])) { $description = $_POST['description']; } else { echo 'Please enter some notes'; }


1

Try this - Add your button inside a form and write down script to add product to the cart and redirect user directly to the checkout page. Suppose, following is the button that you can put on single product page using a WooCommerce hook. <button name="checkout_now"> Checkout Now </button> PHP code: global $woocommerce; $post_id = ...


0

Fixed it with: function fwp_rss_regex ($content) { $content = preg_replace('/\<[^\>]*\>/i','',$content); return $content; }


1

You can use the following functions: time (); return The time by seconds date(); y- Year m- Month d- Day h- Hours i- Minute s- Second for ex: date("Y-m-d H:i:s");


0

I think this will work for you (tried it and it works): date('m', strtotime('0 month')); date('d', strtotime('0 day')); Here is a discussion on the topic.


0

Try this with or without the return. $object_terms = wp_get_object_terms($GLOBALS['post']->ID, 'staff', array('fields' => 'all')); if ($object_terms) { echo '<p>' . '' . '' ; $res = ''; foreach ($object_terms as $term) { $res .= '<a href="' . esc_attr(get_term_link($term, $taxonomy)) . '" title="' . ...


0

Without the HTML code is difficult but i can suggest you to study the new css3 selector, in that case the :first-child https://developer.mozilla.org/en-US/docs/Web/CSS/%3Afirst-child You get a code like this .stats-top .stats-number:first-child{ visibility: hidden; }


0

The function in question is defined in general-template.php, which is loaded unconditionally in wp-settings.php. In other words it should be available in almost any WordPress core load (outside of very rare custom loading routines). My educated guess would be is that some bot simply pings that index.php file directly, without going through WP URL and proper ...


0

The Query Monitor plugin is a very powerful tool for doing this. It shows the template and the queries and hooks the page generates; plus their load order, priority and whether it's core, parent theme, child theme or plugin. Very handle to have in your toolbox! In WP Cli: wp plugin install query-monitor --activate On the repo: ...


0

Use the code functions.php: add_filter('woocommerce_login_redirect', 'wc_login_redirect'); function wc_login_redirect( $redirect_to ) { $redirect_to = 'https://www.example.com/'; return $redirect_to; }


1

NEVER EVER alter any template or file in a theme or plugin that you did not author, and this goes for any core file as well. There is no way to protect the code that you alter or add in any of those files, except maybe changing file permissions, but then again, you will run into other issues ALL customizations should and must be made in either a child theme ...


0

You can use OTF Regenerate Thumbnails. Currently I'm using this with latest WP 4.2.3 and it's working fine without any issue.


0

I just solved this problem, as I was facing the same issue. What is happening when page loads (according to your code): it "gets" the options, then it saves new options. Hence the reason behind option getting updated on page after manual refresh. global $slides; // Add Menu Link add_action( 'admin_menu', 'slider_menu_options' ); function ...


1

I guess you are talking about a specific page, for example domain.com/page? So you can create a generic page template (and select it for the page in WordPress admin panel) or create a template for the specific page. See instructions here. In this template you can add your php code for the redirect. If this redirection would be done for the whole site, not ...


0

Add this code your functions.php Reference : Issue with double dash remove_filter( 'the_title' , 'wptexturize' ); remove_filter( 'the_content' , 'wptexturize' ); remove_filter( 'the_excerpt' , 'wptexturize' ); remove_filter( 'comment_text' , 'wptexturize' ); remove_filter( 'list_cats' , 'wptexturize' );


0

I go the solution to my problem from another forum just now: This was provided by @vrajesh: I replace [/box] to [end-box] and also in grey to 'grey' so my code now looks like this, and it works perfectly. function colored_box_shortcode($atts) { extract(shortcode_atts(array( 'color' => 'grey', ), $atts)); return '<div ...


0

The second argument of any WP shortcode is the content found inside the shortcode block. Additionally, Not sure how you are trying to use forward slash on a shortcode name, slashes are not allowed as a part of shortcode name. Try it like - function colored_box_shortcode( $atts, $content ) { extract( shortcode_atts( array( 'color' => 'grey', ...


2

I don't think that there is a much smarter way to write this code in a procedural style, so basically your code looks okay. But there's a logic error in your body_class_before_header() function which might cause the issue: If the conditional block is not executed, the function will return NULL but as it is a callback on a filter it should always return at ...


0

i fix it and yes it was cache problem i download this plugin and its work fine now http://www.wpbeginner.com/wp-tutorials/how-to-fix-wordpress-website-not-updating-right-away/


0

I played with the code for a bit longer and managed to get it working. Answer below add_filter( 'gform_pre_render', 'freetrial_studios' ); add_filter( 'gform_pre_validation', 'freetrial_studios' ); add_filter( 'gform_pre_submission_filter', 'freetrial_studios' ); add_filter( 'gform_admin_pre_render', 'freetrial_studios' ); function freetrial_studios( $form ...


0

I have Found a way which I use regularly to add my own created PHP to a PHP PAGE or post through the use of Short Codes. Now Create a PHP page named example.php in your theme root directory. write something like: <?php echo "Hi! I am a PHP File in Wordpress template Folder!" ?> Now add the following code to your functions.php function ...


-1

set a permalink structure on settings> permalinks . WordPress needs to create the .htaccess file.


0

WordPress doesn't receive those requests, so the server 404 displays. If you want WordPress to handle all 404s, use mod_rewrite Pretty Permalinks rather than PATHINFO permalinks. The requirements are detailed in Using Permalinks.


0

Add new plugin maybe considered as uploading file. Check if the file uploaded is an image or not before handling if(@!is_array(getimagesize($mediapath))){ $image = true; } else { $image = false; } Thanks to: http://stackoverflow.com/questions/15408125/php-check-if-file-is-an-image So, modify your code to function mdu_validate_image_size( $file ) ...


0

I had this problem and found out right on wp_hash_password() Compare an already hashed password with its plain-text string <?php $wp_hasher = new PasswordHash(8, TRUE); $password_hashed = '$P$B55D6LjfHDkINU5wF.v2BuuzO0/XPk/'; $plain_password = 'test'; if($wp_hasher->CheckPassword($plain_password, $password_hashed)) { echo "YES, Matched"; } ...


0

I was missing quotes around my hidden attribute in my html form. The correct syntax is echo "<input name='mygroup' type='hidden' value=".$_POST['groupname'].">";


1

I am not exactly sure what you are trying to do. However, in the second line of code you have a closing bracket at the end, but there is no opening bracket in your code. Maybe that's the problem?


0

I found a solution to my problem. What I did is the following: First I created a new page in Wordpress with the php that creates the product that has a link like: www.mypagename.com/myphpcode The php is the following: `global $woocommerce; $my_post = array( 'post_title' => 'My title', 'post_content' => 'This is my post.', 'post_status' ...


2

WordPress doesn't use PHP sessions, so WordPress itself can not be related with your sessions working or not regarding if you are logged in or not (I think). Try to call session_start() on init action instead of doing it in a template file and be sure it is called before your custom library is loaded. Also, it can be interesting to end the PHP session on ...


0

Here is my own solution. In my html I've assign id to all the item and inside the form I've added an input option where I pass the value through the script and it was saved later. Simple... script jQuery(document).ready(function($){ $(".sortable").sortable({ connectWith: '.sortable', receive: function (event, ui) { ...


0

Rather that entering form element into the page contents editor in wordpress, make a separate template and load it through "Page Attribute". Then in form action, place below: action="<?php echo home_url('/page-name'); ?>" Let me know if any problems.


0

You are right the action part is the directory to the execution script file. You can not use the static directory path like that, it should be used with get_home_path(); like $path = get_home_path(); then action = '<?php echo $path."wp-includes/tests-form.php" ?>'; More: https://codex.wordpress.org/Function_Reference/get_home_path


0

Based on this question about retrieving Wordpress post slug, you could put together a link like the following: <a href="http://www.example.com/md/<?php global $post; echo $post->post_name; ?>">link text</a> Whether that goes to a functioning page or not, I don't know. It seems like you may want to change rewrite rules in the functions ...


0

name is a WordPress query var, by submitting a form with that var set, you are changing the main query. All form elements should always be prefixed with something unique to prevent clashes like this.


0

In Wordpress dashboard, go to Settings > Permalinks. Click the 'Custom structure' option then put the following code in the box /%post_id%-%postname%/



Top 50 recent answers are included