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

alam7o on "How to using default wordpress add media buttom into content editor"

$
0
0

How to add wordpress add media buttom into content editor of user frontend pro ?

please help me

if not , add a custom media uploader for user


shahayubali on "Display same category post on page with this same page name as page name"

$
0
0

OK... I have a bunch of general pages, then a bunch of posts related to those pages. The posts are in a categories that are named the same as their related Page. What I would like to do is generate a list of the posts on the Page.

I have Pages: "Topic 1" and "Topic 2". I have categories "Topic 1" (slug: topic-1) and "Topic 2" (slug: topic-2). And I have a bunch of posts with those categories.

I want to list "Topic 1" posts on the "Topic 1" page.

I know I can do this:

<?php query_posts('category_name=topic-1&showposts=10'); ?>
<?php while (have_posts()) : the_post(); ?>
<?php the_title(); ?>
<?php endwhile; ?>
But because I have MANY pages to do like this, I would like to be able to use the same page template for all of them.

leapyear16 on "Plugin Shortcode in wordpress 4.5 not Working"

$
0
0

Hello.

This should be very simple but for me, I am learning wordpress for the first time although I am good in PHP.

I would have a php code which I wish to have as a plugin. However, when I paste the shortcode in a post, the shortcode does not work.

Here is a simple plugin I am working with as a dummy.

<?php
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
/*
Plugin Name: My Leap Year
*/
function test() {
echo'Is the shortcode working?';
}
add_shortcode( 'leap', 'test' );

The shortcode [leap] does not work when I paste it in a post/page. How can I make it work?

hedii on "Custom user roles translation not working"

$
0
0

Hi,
I am writing a plugin to create custom user roles and to remove wordpress default user roles except the admin one.

Everything is ok, but custom roles are not translated in the wordpress back-office (in user profil for example, or in settings=>general=>default role).

My plugin code is translation ready: i have created a .pot file and .po and .mo myplugin-fr_FR local. Translation files are ok, because i can see translated description and plugin name in admin plugin page.

/*
Plugin Name: My Website User Roles
Description: Custom user roles and capabilities for my website.
Version:     1.0
Author:      me
License:     GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: my_website_user_roles
Domain Path: /languages
*/
class My_Website_User_Roles {

    public function __construct() {
        // on activation
        register_activation_hook( __FILE__, array( 'My_Website_User_Roles', 'activate' ) );

        /** other stuff like deactivation, etc... */

        // translation
        add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
    }

    public function load_textdomain() {
        load_plugin_textdomain( 'my_website_user_roles', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
    }

    public static function activate() {
        // remove wp default roles except admin
	remove_role( 'editor' );
	remove_role( 'author' );
	remove_role( 'contributor' );
	remove_role( 'subscriber' );

	add_role(
		'basic_contributor',
		__( 'Occasional Contributor', 'my_website_user_roles' ),
		array(
			'read'         => true,
			'edit_posts'   => true,
			'delete_posts' => true,
		)
	);

	add_role(
		'expert_contributor',
		__( 'Expert Contributor', 'my_website_user_roles' ),
		array(
			'read'          => true,
			'edit_posts'    => true,
			'delete_posts'  => true,
			'publish_posts' => false,
			'upload_files'  => true,
			'edit_others_posts' => true,
			'edit_published_posts' => true,
		)
	);

	add_role(
		'moderator',
		__( 'Moderator', 'my_website_user_roles' ),
		array(
			'read'                   => true,
			'edit_posts'             => true,
			'delete_posts'           => true,
			'publish_posts'          => true,
			'edit_published_posts'   => true,
			'delete_published_posts' => true,
			'moderate_comments'      => true,
		)
	);
    }

}

On my languages directory, i have created my_website_user_roles-fr_FR.po and my_website_user_roles-fr_FR.mo files that should translate Occasional Contributor to 'contributeur occasionnel', Expert Contributor to 'contributeur expert' and Moderator to 'modérateur'.
But in the wordpress admin back office, custom user roles are in english but not in french.
Localisation files are loaded because they also translate the plugin description and i can see the description in french on the plugins page.

How can i see the custom user roles in a local language on the back office ? what am i doing wrong ?

applenuggets on "Post thumbnails with different colors based on category?"

$
0
0

I'm really new to coding with wordpress/PHP and I'm struggling to figure out how implement different styles for thumbnails depending on their category.

Right now I'm making a news website with 4 categories (news, sports, entertainment, columns) and each category has a different color associated with it. I'd like for the thumbnails and excerpts to display the color of the category it's in. I'm trying to insert the post category into a class which I can then style, but I just get a bunch of one random category listed as links at the top of my grid instead of my thumbnails getting an actual class/id. This is the current code for my thumbnails:

<?php
			  $thumbnails = get_posts('numberposts=6');
			  foreach ($thumbnails as $thumbnail) {
			    if ( has_post_thumbnail($thumbnail->ID)) {
			      echo '<div class="small_feature"><a href="' . get_permalink( $thumbnail->ID ) . '" title="' . esc_attr( $thumbnail->post_title ) . '"><div class="colored_bar' . the_category( ' ' ) . '"></div>';
			      echo get_the_post_thumbnail($thumbnail->ID, 'thumbnail');
			      echo '<div class="overlay_bar"> <h2 class="post_title_thumbnail"> ' . esc_attr( $thumbnail->post_title ) . '</h2></div></a></div>';
			    }
			  }
			?>

Which results in this, links to one random category and no id or class in the actual colored bar:
Link

This is what I want, each side colored bar is a different color corresponding to its category:
Link

Thanks, any help would be appreciated!

andygo12 on "Shortcode / function only working for first post rendered by loop archive page"

$
0
0

Hi there,

I have a custom post archive displaying post and author meta at roadtripsharing.com/road_trip

In the archive template I added a do_shortcode(); in the loop, specifically related to the "New Message" button which opens a dialogue to send a direct message to users. Clicking the button only triggers the dialogue for the first post display (though the button does show on all posts, which is even more bizarre). I tried this with a gravity forms shortcode as well and it only rendered the form in the first (top-most) post on the page.

To simplify the question and perhaps make it more useful to others: Suppose I only wanted to show the post title and the shortcode. Would/should this be correct to make the shortcode fully work for all posts?

<?php get_header(); ?>
    <?php $road_trips = new WP_Query(array(
    'post_type' => 'road_trip'
    )); ?>
    <?php while($road_trips->have_posts()) : $road_trips->the_post(); ?>
    <div>
      <?php echo get_the_title(); ?>
      <?php echo do_shortcode('[shortcode]'); ?>
    </div>
    <?php endwhile; ?>
    <?php get_footer(); ?>

Here is the code for the actual shortcode as far as I can tell from the plugin source code:

[Large code excerpt removed by moderator per forum rules. Please use the pastebin for all large code excerpts. It works better anyway.]

The add_shortcode call, also in plugin file:

add_shortcode(WPS_PREFIX.'-mail-post', 'wps_mail_post');

However I've also tested it with a couple different shortcodes from different plugins. I have heard from another forum that the issue might be with the shortcode handler not being designed to work more than once per page. If there's a limitation with the shortcode handler, how can that be overcome to display multiple shortcodes per page?

UPDATE: Replaced do_shortcode call with

<?php echo wps_mail_post(); ?>

and that's giving a missing argument error and also only working correctly (clicking "New Message" opens the message dialogue) for the top post at roadtripsharing.com/road_trip (the corresponding buttons on other posts only trigger page refresh and navigation to top of page).

Will look into the $args but what's up with the functions only working for the first post / how to fix it? If the same issue is occuring with the function pasted in rather than using do_shortcode does that mean the issue is not with the shortcode handler after all?

Any tips for getting shortcodes to work for each rendered item in an archive, and not just the first one?

m_pahlevanzadeh on "How to use my API , But safe from sql injection?"

$
0
0

I need to store my url and then fetch them and redirect to some sites.
But I don't know how to redirect and fetch data But secure from sql injection.
Before any help, Thank you!

jvdeud on "Is this possible with rewrites?"

$
0
0

I'm aiming at creating my own plugin but i'm having some troubles figuring out with the rewriting and so on. What i'm trying to build is that my client(s) can created their own "Vehicles". Well that ain't that to hard but in the same plugin, they should be able to create brands and variants of the car.

So they can create an "Audi" as brand and "Q3" as car. But the Q3 has multiple Variants like Ultra, Sport and so on. So in the end you would get Audi Q3 Ultra.

However as link i would like to have the following: audi/q3/ultra. The best situation if possible, would be if the client creates an page called "Audi", my plugin(post/pagetype) is defined as example "cars", the link would be: /audi/cars/q3/ultra. Is this possible within WordPress? Cause if they gave multiple brands, it could be the url "volkswagen/cars/polo/sport".

Do you have to create multiple post types for this? Is this possible with the rewritng at all? I would like it to that "Brands" and "Cars" have their own page with information.

Looking forward to hear some options ans how so!


arjungowda123 on "How to secure the mysql DB password in wp-config.php"

$
0
0

Hi,

I been reading the blogs and forms within Wordpress regarding the encryption of mysql DB password. Similar questions were asking long back and the reply was that the password cannot be encrypted. Is it still true? Is there no way to to encrypt the password.
I also read about the moving the wp-config.php file away from Wordpress directory but it has its own issues.

Please suggest on the password encryption.

Regards,
AG.

serviceman on "How to filter entire blog by category"

$
0
0

Is there a way to filter the blog by entire category. For example, if I have two categories travel and sports I only want the travel articles to show on the blog unless I set a variable somewhere for sports to show instead.

I hope I am explaining this correctly. Basically I want to limit plugins, search etc to one parent category.

jellygonuts on "Unknown Core file additions"

$
0
0

I have several additions to my core files as of 4/20/2016. I can't find anything about them by searching online, which seems fishy! They are:

~1.78K April 19, 2016 2:14 pm .QWPCLI_htaccess.20160420_0913
~235.00B April 20, 2016 3:13 pm .QWPCLI_htaccess.20160420_0914
~5.05M April 20, 2016 2:47 pm QWPCLI_CORE_2016_04_20-14_46.tar.gz
~25.32M April 20, 2016 3:14 pm QWPCLI_CORE_2016_04_20_09-14.tar.gz

Do these seem legit, or should I be worried about being hacked?

flister98 on "what is this"

mae48 on "Add quantity box woocommerce"

$
0
0

Hi, I'm building a woocommerce site and I want it to have an adult quantity and child quantity to add to cart...How can I do that?

Floppy78 on "Custom Post Type Rewrite Permalink"

$
0
0

Hi everyone!
I'm working with a premium theme in which was developed a plugin for custom post types. The site presents a listing of events and locations. I'd like to change the permalink structure for SEO purposes and maybe I'm not so experienced in coding to understand how to achieve my goal (if possible).

This is the code for events categories:

register_taxonomy(
				'event_cat',
				'event',
				array(
					'public'=>true,
					'hierarchical' => true,
					'labels'=> $labels,
					'query_var' => 'event_cat',
					'show_ui' => true,
					'rewrite' => array( 'slug' => 'event_cat', 'with_front' => false ),
				)
			);

And this is the permalink output:
http://www.vadoper.it/demo/event_cat/concerto-dal-vivo/
I'd like to get rid of this "event_cat" (I was expecting to see it substituted by the category name, but this is appended after "event_cat" instead) just to have a simple permalink for categories like .

Maybe I'm missing something about the theme architecture and, even for instructive purposes, I hope someone could help me understand more about these permalinks.

My try has been changing the "rewrite" code with 'rewrite' => array( 'slug' => '', 'with_front' => false ),
re-save permalinks (actually setted to /%postname%/) but it isn't working..
Thank you!

lyssycreates on "Changing Pinterest Share Button"

$
0
0

I'm using Solopine's Florence theme. The default sharing button at the bottom of each post shares the featured image, and the Pin description is the title of my blog post.

I'd like to change it such that when someone clicks on that same sharing button, they can choose from all the images in the blog post to pin.

Please advise if I need to get a plugin or custom code this! TIA!


chef30 on "How to print wordpress admin url on page"

$
0
0

I'm trying to print the my admin url on all of my pages (yes I am aware of the security implications). I've been messing around with 'echo' and 'admin_url()' to no avail

This is the code i've tried that hasn't worked
<? echo admin_url(); ?>

Also, once I get the correct coding, what file should I put it? Wouldn't it be single.php?

TrishaM on "SQL query to delete metadata of a custom post type, not the post"

$
0
0

I posted this question on StackExchange but not getting answers, hoping someone here can help.....

I have a custom post type with a metakey/value associated for which I need to delete the metadata, but not the post itself.

This is further complicated by the fact that 2 other post types ('post' and 2 other CPTs) also have this same metakey/value pair, and I don't want to delete the metadata associated with those other post types, just one particular post type......so I can't just clean this metadata out of the wp_postmeta table without specifying which post type to isolate.

My SQL skills are not good enough yet to do this without a mistake (although I do have my DB backed up), I would be very grateful for any help.

Custom post type is 'deal'.
Metakey is 'resort_chain'.

Background if anyone is interested or would find it helpful: We setup a CPT with custom fields using ACF Pro, but found (after entering many hundreds of 'deals') that we were entering a lot of data that is better associated with the 'resort' and the 'deal' entry could be made much faster and more efficient by setting up another CPT ('resort') and associating a lot of the metadata with the Resort - that way many deals can be entered for each resort without repetitively entering resort information. That data is now associated to the Deal via a (ACF) 'relationship' field.

BUT I need to clean out the data that is still attached to the Deal(s) so that I can properly test the search/filter function as well as the template display.

I just want to be sure that I remove that data only from Deals posts and not from Resorts posts or our other custom post type ('faqs') - both of which do contain a lot of the same metadata.

renitro on "hide div product price"

$
0
0

Hi.
I have a woocoomerce
on the product page I have a div.
I need that div is hidden when the product price is less than 200.
Could anyone help me?
I tried with this:

<Div id = "foo" <? Php $ price = $ product-> get_price_html (); if (($ price> 200)) {echo 'style = "display: none;"'; }? >>

text
</ Div>

any ideas?

thisabundantlife on "My Blog is Gone"

$
0
0

I haven't been on my blog in a while and when I just checked it, it is giving me an Apache Server a Port 80 message. Not sure what to do because I can't even log on as admin. Help! The site is http://www.thisabundantlifeblog.com

stdesigner on "Shortcode mod request - Display Post by language on homepage"

$
0
0

Hi Guys,

I'm still new with Wordpress and I have the following issue. I bought a theme in which I had a shortcode to display blog post on the home page. Problem is, it uses IDs to identify Post and my site is bilingual (EN & FR), therefore I have all post in all language on each homepage.

Is there a way to identify the language within the shortcode so it displays EN post on EN homepage and FR post on FR homepage?

Here's the code :

function trend_show_blog_post_shortcode( $params, $content ) {
    extract( shortcode_atts(
        array(
            'number'       => '',
            'columns'    => ''
           ), $params ) );
    $args_posts = array(
            'posts_per_page'        => $number,
            'post_type'             => 'post',
            'post_status'           => 'publish'
        );
    $posts = get_posts($args_posts);
    $shortcode_content = '<div class="trend_shortcode_blog vc_row sticky-posts">';
    foreach ($posts as $post) {
        $excerpt = get_post_field('post_content', $post->ID);
        $thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ),'portfolio_pic700x450' );
        $author_id = $post->post_author;
        $url = get_permalink($post->ID); /* ISSUE HERE SINCE ID DIFFERENT EACH LANG */
        $shortcode_content .= '<div class="'.$columns.' post">';
            $shortcode_content .= '<a href="'.$url.'" class="relative">';
                if($thumbnail_src) {
                    $shortcode_content .= '<img src="'. $thumbnail_src[0] . '" alt="'. $post->post_title .'" />';
                }else{
                    $shortcode_content .= '<img src="http://placehold.it/700x450" alt="'. $post->post_title .'" />';
                }
                $shortcode_content .= '<div class="post-date absolute rotate45">';
                    $shortcode_content .= '<span class="rotate45_back">'.get_the_date( "j M" ).'</span>';
                $shortcode_content .= '</div>';
                $shortcode_content .= '<div class="thumbnail-overlay absolute">';
                    $shortcode_content .= '<i class="fa fa-plus absolute"></i>';
                $shortcode_content .= '</div>';
            $shortcode_content .= '</a>';
            $shortcode_content .= '<h3 class="post-name"><a href="'.$url.'">'.$post->post_title.'</a></h3>';
            $shortcode_content .= '<div class="post-author">by '.get_the_author_meta( 'display_name', $author_id ).'</div>';
            $shortcode_content .= '<div class="post-excerpt">'.trend_excerpt_limit($excerpt,10).'</div>';
        $shortcode_content .= '</div>';
    }
    $shortcode_content .= '</div>';
    return $shortcode_content;
}
add_shortcode('trend-blog-posts', 'trend_show_blog_post_shortcode');

Thanks in advance.

JP

Viewing all 8245 articles
Browse latest View live




Latest Images